Package compute is an auto-generated package for the Google Compute Engine API.
General documentation
For information that is relevant for all client libraries please reference https://pkg.go.dev/cloud.google.com/go#pkg-overview. Some information on this page includes:
- Authentication and Authorization
- Timeouts and Cancellation
- Testing against Client Libraries
- Debugging Client Libraries
- Inspecting errors
Example usage
To get started with this package, create a client.
// go get cloud.google.com/go/compute/apiv1@latest ctx := context.Background() // This snippet has been automatically generated and should be regarded as a code template only. // It will require modifications to work: // - It may require correct/in-range values for request initialization. // - It may require specifying regional endpoints when creating the service client as shown in: // https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options c, err := compute.NewAcceleratorTypesClient(ctx) if err != nil { // TODO: Handle error. } defer c.Close()
The client will use your default application credentials. Clients should be reused instead of created as needed. The methods of Client are safe for concurrent use by multiple goroutines. The returned client must be Closed when it is done being used.
Using the Client
The following is an example of making an API call with the newly created client, mentioned above.
req := &computepb.AggregatedListAcceleratorTypesRequest{ // TODO: Fill request struct fields. // See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListAcceleratorTypesRequest. } it := c.AggregatedList(ctx, req) for { resp, err := it.Next() if err == iterator.Done { break } if err != nil { // TODO: Handle error. } // TODO: Use resp. _ = resp // If you need to access the underlying RPC response, // you can do so by casting the `Response` as below. // Otherwise, remove this line. Only populated after // first call to Next(). Not safe for concurrent access. _ = it.Response.(*computepb.AcceleratorTypeAggregatedList) }
Use of Context
The ctx passed to NewAcceleratorTypesClient is used for authentication requests and for creating the underlying connection, but is not used for subsequent calls. Individual methods on the client use the ctx given to them.
To close the open connection, use the Close() method.
Functions
func DefaultAuthScopes
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
AcceleratorTypeIterator
type AcceleratorTypeIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.AcceleratorType, nextPageToken string, err error)
// contains filtered or unexported fields
}
AcceleratorTypeIterator manages a stream of *computepb.AcceleratorType.
func (*AcceleratorTypeIterator) All
func (it *AcceleratorTypeIterator) All() iter.Seq2[*computepb.AcceleratorType, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AcceleratorTypeIterator) Next
func (it *AcceleratorTypeIterator) Next() (*computepb.AcceleratorType, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AcceleratorTypeIterator) PageInfo
func (it *AcceleratorTypeIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
AcceleratorTypesCallOptions
type AcceleratorTypesCallOptions struct {
AggregatedList []gax.CallOption
Get []gax.CallOption
List []gax.CallOption
}
AcceleratorTypesCallOptions contains the retry settings for each method of AcceleratorTypesClient.
AcceleratorTypesClient
type AcceleratorTypesClient struct {
// The call options for this service.
CallOptions *AcceleratorTypesCallOptions
// contains filtered or unexported fields
}
AcceleratorTypesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
Services
The AcceleratorTypes API.
func NewAcceleratorTypesRESTClient
func NewAcceleratorTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*AcceleratorTypesClient, error)
NewAcceleratorTypesRESTClient creates a new accelerator types rest client.
Services
The AcceleratorTypes API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAcceleratorTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*AcceleratorTypesClient) AggregatedList
func (c *AcceleratorTypesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListAcceleratorTypesRequest, opts ...gax.CallOption) *AcceleratorTypesScopedListPairIterator
AggregatedList retrieves an aggregated list of accelerator types. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAcceleratorTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListAcceleratorTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListAcceleratorTypesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.AcceleratorTypeAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAcceleratorTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListAcceleratorTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListAcceleratorTypesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*AcceleratorTypesClient) Close
func (c *AcceleratorTypesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*AcceleratorTypesClient) Connection (deprecated)
func (c *AcceleratorTypesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*AcceleratorTypesClient) Get
func (c *AcceleratorTypesClient) Get(ctx context.Context, req *computepb.GetAcceleratorTypeRequest, opts ...gax.CallOption) (*computepb.AcceleratorType, error)
Get returns the specified accelerator type.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAcceleratorTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetAcceleratorTypeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetAcceleratorTypeRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*AcceleratorTypesClient) List
func (c *AcceleratorTypesClient) List(ctx context.Context, req *computepb.ListAcceleratorTypesRequest, opts ...gax.CallOption) *AcceleratorTypeIterator
List retrieves a list of accelerator types that are available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAcceleratorTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListAcceleratorTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListAcceleratorTypesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.AcceleratorTypeList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAcceleratorTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListAcceleratorTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListAcceleratorTypesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
AcceleratorTypesScopedListPair
type AcceleratorTypesScopedListPair struct {
Key string
Value *computepb.AcceleratorTypesScopedList
}
AcceleratorTypesScopedListPair is a holder type for string/*computepb.AcceleratorTypesScopedList map entries
AcceleratorTypesScopedListPairIterator
type AcceleratorTypesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []AcceleratorTypesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
AcceleratorTypesScopedListPairIterator manages a stream of AcceleratorTypesScopedListPair.
func (*AcceleratorTypesScopedListPairIterator) All
func (it *AcceleratorTypesScopedListPairIterator) All() iter.Seq2[AcceleratorTypesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AcceleratorTypesScopedListPairIterator) Next
func (it *AcceleratorTypesScopedListPairIterator) Next() (AcceleratorTypesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AcceleratorTypesScopedListPairIterator) PageInfo
func (it *AcceleratorTypesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
AddressIterator
type AddressIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.Address, nextPageToken string, err error)
// contains filtered or unexported fields
}
AddressIterator manages a stream of *computepb.Address.
func (*AddressIterator) All
func (it *AddressIterator) All() iter.Seq2[*computepb.Address, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AddressIterator) Next
func (it *AddressIterator) Next() (*computepb.Address, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AddressIterator) PageInfo
func (it *AddressIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
AddressesCallOptions
type AddressesCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Move []gax.CallOption
SetLabels []gax.CallOption
}
AddressesCallOptions contains the retry settings for each method of AddressesClient.
AddressesClient
type AddressesClient struct {
// The call options for this service.
CallOptions *AddressesCallOptions
// contains filtered or unexported fields
}
AddressesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Addresses API.
func NewAddressesRESTClient
func NewAddressesRESTClient(ctx context.Context, opts ...option.ClientOption) (*AddressesClient, error)
NewAddressesRESTClient creates a new addresses rest client.
The Addresses API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*AddressesClient) AggregatedList
func (c *AddressesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListAddressesRequest, opts ...gax.CallOption) *AddressesScopedListPairIterator
AggregatedList retrieves an aggregated list of addresses. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListAddressesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListAddressesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.AddressAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListAddressesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListAddressesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*AddressesClient) Close
func (c *AddressesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*AddressesClient) Connection (deprecated)
func (c *AddressesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*AddressesClient) Delete
func (c *AddressesClient) Delete(ctx context.Context, req *computepb.DeleteAddressRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified address resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteAddressRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*AddressesClient) Get
func (c *AddressesClient) Get(ctx context.Context, req *computepb.GetAddressRequest, opts ...gax.CallOption) (*computepb.Address, error)
Get returns the specified address resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetAddressRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*AddressesClient) Insert
func (c *AddressesClient) Insert(ctx context.Context, req *computepb.InsertAddressRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an address resource in the specified project by using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertAddressRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*AddressesClient) List
func (c *AddressesClient) List(ctx context.Context, req *computepb.ListAddressesRequest, opts ...gax.CallOption) *AddressIterator
List retrieves a list of addresses contained within the specified region.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListAddressesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListAddressesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.AddressList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListAddressesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListAddressesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*AddressesClient) Move
func (c *AddressesClient) Move(ctx context.Context, req *computepb.MoveAddressRequest, opts ...gax.CallOption) (*Operation, error)
Move moves the specified address resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.MoveAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#MoveAddressRequest.
}
op, err := c.Move(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*AddressesClient) SetLabels
func (c *AddressesClient) SetLabels(ctx context.Context, req *computepb.SetLabelsAddressRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on an Address. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsAddressRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
AddressesScopedListPair
type AddressesScopedListPair struct {
Key string
Value *computepb.AddressesScopedList
}
AddressesScopedListPair is a holder type for string/*computepb.AddressesScopedList map entries
AddressesScopedListPairIterator
type AddressesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []AddressesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
AddressesScopedListPairIterator manages a stream of AddressesScopedListPair.
func (*AddressesScopedListPairIterator) All
func (it *AddressesScopedListPairIterator) All() iter.Seq2[AddressesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AddressesScopedListPairIterator) Next
func (it *AddressesScopedListPairIterator) Next() (AddressesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AddressesScopedListPairIterator) PageInfo
func (it *AddressesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
AutoscalerIterator
type AutoscalerIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.Autoscaler, nextPageToken string, err error)
// contains filtered or unexported fields
}
AutoscalerIterator manages a stream of *computepb.Autoscaler.
func (*AutoscalerIterator) All
func (it *AutoscalerIterator) All() iter.Seq2[*computepb.Autoscaler, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AutoscalerIterator) Next
func (it *AutoscalerIterator) Next() (*computepb.Autoscaler, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AutoscalerIterator) PageInfo
func (it *AutoscalerIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
AutoscalersCallOptions
type AutoscalersCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
Update []gax.CallOption
}
AutoscalersCallOptions contains the retry settings for each method of AutoscalersClient.
AutoscalersClient
type AutoscalersClient struct {
// The call options for this service.
CallOptions *AutoscalersCallOptions
// contains filtered or unexported fields
}
AutoscalersClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Autoscalers API.
func NewAutoscalersRESTClient
func NewAutoscalersRESTClient(ctx context.Context, opts ...option.ClientOption) (*AutoscalersClient, error)
NewAutoscalersRESTClient creates a new autoscalers rest client.
The Autoscalers API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*AutoscalersClient) AggregatedList
func (c *AutoscalersClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListAutoscalersRequest, opts ...gax.CallOption) *AutoscalersScopedListPairIterator
AggregatedList retrieves an aggregated list of autoscalers. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListAutoscalersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListAutoscalersRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.AutoscalerAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListAutoscalersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListAutoscalersRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*AutoscalersClient) Close
func (c *AutoscalersClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*AutoscalersClient) Connection (deprecated)
func (c *AutoscalersClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*AutoscalersClient) Delete
func (c *AutoscalersClient) Delete(ctx context.Context, req *computepb.DeleteAutoscalerRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified autoscaler.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteAutoscalerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteAutoscalerRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*AutoscalersClient) Get
func (c *AutoscalersClient) Get(ctx context.Context, req *computepb.GetAutoscalerRequest, opts ...gax.CallOption) (*computepb.Autoscaler, error)
Get returns the specified autoscaler resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetAutoscalerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetAutoscalerRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*AutoscalersClient) Insert
func (c *AutoscalersClient) Insert(ctx context.Context, req *computepb.InsertAutoscalerRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an autoscaler in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertAutoscalerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertAutoscalerRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*AutoscalersClient) List
func (c *AutoscalersClient) List(ctx context.Context, req *computepb.ListAutoscalersRequest, opts ...gax.CallOption) *AutoscalerIterator
List retrieves a list of autoscalers contained within the specified zone.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListAutoscalersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListAutoscalersRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.AutoscalerList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListAutoscalersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListAutoscalersRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*AutoscalersClient) Patch
func (c *AutoscalersClient) Patch(ctx context.Context, req *computepb.PatchAutoscalerRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates an autoscaler in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchAutoscalerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchAutoscalerRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*AutoscalersClient) Update
func (c *AutoscalersClient) Update(ctx context.Context, req *computepb.UpdateAutoscalerRequest, opts ...gax.CallOption) (*Operation, error)
Update updates an autoscaler in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewAutoscalersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateAutoscalerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateAutoscalerRequest.
}
op, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
AutoscalersScopedListPair
type AutoscalersScopedListPair struct {
Key string
Value *computepb.AutoscalersScopedList
}
AutoscalersScopedListPair is a holder type for string/*computepb.AutoscalersScopedList map entries
AutoscalersScopedListPairIterator
type AutoscalersScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []AutoscalersScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
AutoscalersScopedListPairIterator manages a stream of AutoscalersScopedListPair.
func (*AutoscalersScopedListPairIterator) All
func (it *AutoscalersScopedListPairIterator) All() iter.Seq2[AutoscalersScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*AutoscalersScopedListPairIterator) Next
func (it *AutoscalersScopedListPairIterator) Next() (AutoscalersScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*AutoscalersScopedListPairIterator) PageInfo
func (it *AutoscalersScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
BackendBucketIterator
type BackendBucketIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.BackendBucket, nextPageToken string, err error)
// contains filtered or unexported fields
}
BackendBucketIterator manages a stream of *computepb.BackendBucket.
func (*BackendBucketIterator) All
func (it *BackendBucketIterator) All() iter.Seq2[*computepb.BackendBucket, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*BackendBucketIterator) Next
func (it *BackendBucketIterator) Next() (*computepb.BackendBucket, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*BackendBucketIterator) PageInfo
func (it *BackendBucketIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
BackendBucketsCallOptions
type BackendBucketsCallOptions struct {
AddSignedUrlKey []gax.CallOption
Delete []gax.CallOption
DeleteSignedUrlKey []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetEdgeSecurityPolicy []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
Update []gax.CallOption
}
BackendBucketsCallOptions contains the retry settings for each method of BackendBucketsClient.
BackendBucketsClient
type BackendBucketsClient struct {
// The call options for this service.
CallOptions *BackendBucketsCallOptions
// contains filtered or unexported fields
}
BackendBucketsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The BackendBuckets API.
func NewBackendBucketsRESTClient
func NewBackendBucketsRESTClient(ctx context.Context, opts ...option.ClientOption) (*BackendBucketsClient, error)
NewBackendBucketsRESTClient creates a new backend buckets rest client.
The BackendBuckets API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*BackendBucketsClient) AddSignedUrlKey
func (c *BackendBucketsClient) AddSignedUrlKey(ctx context.Context, req *computepb.AddSignedUrlKeyBackendBucketRequest, opts ...gax.CallOption) (*Operation, error)
AddSignedUrlKey adds a key for validating requests with signed URLs for this backend bucket.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddSignedUrlKeyBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddSignedUrlKeyBackendBucketRequest.
}
op, err := c.AddSignedUrlKey(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendBucketsClient) Close
func (c *BackendBucketsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*BackendBucketsClient) Connection (deprecated)
func (c *BackendBucketsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*BackendBucketsClient) Delete
func (c *BackendBucketsClient) Delete(ctx context.Context, req *computepb.DeleteBackendBucketRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified BackendBucket resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteBackendBucketRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendBucketsClient) DeleteSignedUrlKey
func (c *BackendBucketsClient) DeleteSignedUrlKey(ctx context.Context, req *computepb.DeleteSignedUrlKeyBackendBucketRequest, opts ...gax.CallOption) (*Operation, error)
DeleteSignedUrlKey deletes a key for validating requests with signed URLs for this backend bucket.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteSignedUrlKeyBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteSignedUrlKeyBackendBucketRequest.
}
op, err := c.DeleteSignedUrlKey(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendBucketsClient) Get
func (c *BackendBucketsClient) Get(ctx context.Context, req *computepb.GetBackendBucketRequest, opts ...gax.CallOption) (*computepb.BackendBucket, error)
Get returns the specified BackendBucket resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetBackendBucketRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendBucketsClient) GetIamPolicy
func (c *BackendBucketsClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyBackendBucketRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyBackendBucketRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendBucketsClient) Insert
func (c *BackendBucketsClient) Insert(ctx context.Context, req *computepb.InsertBackendBucketRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a BackendBucket resource in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertBackendBucketRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendBucketsClient) List
func (c *BackendBucketsClient) List(ctx context.Context, req *computepb.ListBackendBucketsRequest, opts ...gax.CallOption) *BackendBucketIterator
List retrieves the list of BackendBucket resources available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListBackendBucketsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListBackendBucketsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.BackendBucketList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListBackendBucketsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListBackendBucketsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*BackendBucketsClient) Patch
func (c *BackendBucketsClient) Patch(ctx context.Context, req *computepb.PatchBackendBucketRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates the specified BackendBucket resource with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchBackendBucketRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendBucketsClient) SetEdgeSecurityPolicy
func (c *BackendBucketsClient) SetEdgeSecurityPolicy(ctx context.Context, req *computepb.SetEdgeSecurityPolicyBackendBucketRequest, opts ...gax.CallOption) (*Operation, error)
SetEdgeSecurityPolicy sets the edge security policy for the specified backend bucket.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetEdgeSecurityPolicyBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetEdgeSecurityPolicyBackendBucketRequest.
}
op, err := c.SetEdgeSecurityPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendBucketsClient) SetIamPolicy
func (c *BackendBucketsClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyBackendBucketRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyBackendBucketRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendBucketsClient) TestIamPermissions
func (c *BackendBucketsClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsBackendBucketRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsBackendBucketRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendBucketsClient) Update
func (c *BackendBucketsClient) Update(ctx context.Context, req *computepb.UpdateBackendBucketRequest, opts ...gax.CallOption) (*Operation, error)
Update updates the specified BackendBucket resource with the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendBucketsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateBackendBucketRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateBackendBucketRequest.
}
op, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
BackendServiceIterator
type BackendServiceIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.BackendService, nextPageToken string, err error)
// contains filtered or unexported fields
}
BackendServiceIterator manages a stream of *computepb.BackendService.
func (*BackendServiceIterator) All
func (it *BackendServiceIterator) All() iter.Seq2[*computepb.BackendService, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*BackendServiceIterator) Next
func (it *BackendServiceIterator) Next() (*computepb.BackendService, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*BackendServiceIterator) PageInfo
func (it *BackendServiceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
BackendServicesCallOptions
type BackendServicesCallOptions struct {
AddSignedUrlKey []gax.CallOption
AggregatedList []gax.CallOption
Delete []gax.CallOption
DeleteSignedUrlKey []gax.CallOption
Get []gax.CallOption
GetHealth []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListUsable []gax.CallOption
Patch []gax.CallOption
SetEdgeSecurityPolicy []gax.CallOption
SetIamPolicy []gax.CallOption
SetSecurityPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
Update []gax.CallOption
}
BackendServicesCallOptions contains the retry settings for each method of BackendServicesClient.
BackendServicesClient
type BackendServicesClient struct {
// The call options for this service.
CallOptions *BackendServicesCallOptions
// contains filtered or unexported fields
}
BackendServicesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The BackendServices API.
func NewBackendServicesRESTClient
func NewBackendServicesRESTClient(ctx context.Context, opts ...option.ClientOption) (*BackendServicesClient, error)
NewBackendServicesRESTClient creates a new backend services rest client.
The BackendServices API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*BackendServicesClient) AddSignedUrlKey
func (c *BackendServicesClient) AddSignedUrlKey(ctx context.Context, req *computepb.AddSignedUrlKeyBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)
AddSignedUrlKey adds a key for validating requests with signed URLs for this backend service.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddSignedUrlKeyBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddSignedUrlKeyBackendServiceRequest.
}
op, err := c.AddSignedUrlKey(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendServicesClient) AggregatedList
func (c *BackendServicesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListBackendServicesRequest, opts ...gax.CallOption) *BackendServicesScopedListPairIterator
AggregatedList retrieves the list of all BackendService resources, regional and global, available to the specified project. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListBackendServicesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListBackendServicesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.BackendServiceAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListBackendServicesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListBackendServicesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*BackendServicesClient) Close
func (c *BackendServicesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*BackendServicesClient) Connection (deprecated)
func (c *BackendServicesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*BackendServicesClient) Delete
func (c *BackendServicesClient) Delete(ctx context.Context, req *computepb.DeleteBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified BackendService resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteBackendServiceRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendServicesClient) DeleteSignedUrlKey
func (c *BackendServicesClient) DeleteSignedUrlKey(ctx context.Context, req *computepb.DeleteSignedUrlKeyBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)
DeleteSignedUrlKey deletes a key for validating requests with signed URLs for this backend service.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteSignedUrlKeyBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteSignedUrlKeyBackendServiceRequest.
}
op, err := c.DeleteSignedUrlKey(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendServicesClient) Get
func (c *BackendServicesClient) Get(ctx context.Context, req *computepb.GetBackendServiceRequest, opts ...gax.CallOption) (*computepb.BackendService, error)
Get returns the specified BackendService resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetBackendServiceRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendServicesClient) GetHealth
func (c *BackendServicesClient) GetHealth(ctx context.Context, req *computepb.GetHealthBackendServiceRequest, opts ...gax.CallOption) (*computepb.BackendServiceGroupHealth, error)
GetHealth gets the most recent health check results for this BackendService. Example request body: { “group”: “/zones/us-east1-b/instanceGroups/lb-backend-example” }
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetHealthBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetHealthBackendServiceRequest.
}
resp, err := c.GetHealth(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendServicesClient) GetIamPolicy
func (c *BackendServicesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyBackendServiceRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyBackendServiceRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendServicesClient) Insert
func (c *BackendServicesClient) Insert(ctx context.Context, req *computepb.InsertBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a BackendService resource in the specified project using the data included in the request. For more information, see Backend services overview .
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertBackendServiceRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendServicesClient) List
func (c *BackendServicesClient) List(ctx context.Context, req *computepb.ListBackendServicesRequest, opts ...gax.CallOption) *BackendServiceIterator
List retrieves the list of BackendService resources available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListBackendServicesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListBackendServicesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.BackendServiceList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListBackendServicesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListBackendServicesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*BackendServicesClient) ListUsable
func (c *BackendServicesClient) ListUsable(ctx context.Context, req *computepb.ListUsableBackendServicesRequest, opts ...gax.CallOption) *BackendServiceIterator
ListUsable retrieves a list of all usable backend services in the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListUsableBackendServicesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListUsableBackendServicesRequest.
}
it := c.ListUsable(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.BackendServiceListUsable)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListUsableBackendServicesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListUsableBackendServicesRequest.
}
for resp, err := range c.ListUsable(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*BackendServicesClient) Patch
func (c *BackendServicesClient) Patch(ctx context.Context, req *computepb.PatchBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)
Patch patches the specified BackendService resource with the data included in the request. For more information, see Backend services overview. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchBackendServiceRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendServicesClient) SetEdgeSecurityPolicy
func (c *BackendServicesClient) SetEdgeSecurityPolicy(ctx context.Context, req *computepb.SetEdgeSecurityPolicyBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)
SetEdgeSecurityPolicy sets the edge security policy for the specified backend service.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetEdgeSecurityPolicyBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetEdgeSecurityPolicyBackendServiceRequest.
}
op, err := c.SetEdgeSecurityPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendServicesClient) SetIamPolicy
func (c *BackendServicesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyBackendServiceRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyBackendServiceRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendServicesClient) SetSecurityPolicy
func (c *BackendServicesClient) SetSecurityPolicy(ctx context.Context, req *computepb.SetSecurityPolicyBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)
SetSecurityPolicy sets the Google Cloud Armor security policy for the specified backend service. For more information, see Google Cloud Armor Overview
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetSecurityPolicyBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetSecurityPolicyBackendServiceRequest.
}
op, err := c.SetSecurityPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*BackendServicesClient) TestIamPermissions
func (c *BackendServicesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsBackendServiceRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsBackendServiceRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*BackendServicesClient) Update
func (c *BackendServicesClient) Update(ctx context.Context, req *computepb.UpdateBackendServiceRequest, opts ...gax.CallOption) (*Operation, error)
Update updates the specified BackendService resource with the data included in the request. For more information, see Backend services overview.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewBackendServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateBackendServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateBackendServiceRequest.
}
op, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
BackendServicesScopedListPair
type BackendServicesScopedListPair struct {
Key string
Value *computepb.BackendServicesScopedList
}
BackendServicesScopedListPair is a holder type for string/*computepb.BackendServicesScopedList map entries
BackendServicesScopedListPairIterator
type BackendServicesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []BackendServicesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
BackendServicesScopedListPairIterator manages a stream of BackendServicesScopedListPair.
func (*BackendServicesScopedListPairIterator) All
func (it *BackendServicesScopedListPairIterator) All() iter.Seq2[BackendServicesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*BackendServicesScopedListPairIterator) Next
func (it *BackendServicesScopedListPairIterator) Next() (BackendServicesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*BackendServicesScopedListPairIterator) PageInfo
func (it *BackendServicesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
BgpRouteIterator
type BgpRouteIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.BgpRoute, nextPageToken string, err error)
// contains filtered or unexported fields
}
BgpRouteIterator manages a stream of *computepb.BgpRoute.
func (*BgpRouteIterator) All
func (it *BgpRouteIterator) All() iter.Seq2[*computepb.BgpRoute, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*BgpRouteIterator) Next
func (it *BgpRouteIterator) Next() (*computepb.BgpRoute, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*BgpRouteIterator) PageInfo
func (it *BgpRouteIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
CommitmentIterator
type CommitmentIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.Commitment, nextPageToken string, err error)
// contains filtered or unexported fields
}
CommitmentIterator manages a stream of *computepb.Commitment.
func (*CommitmentIterator) All
func (it *CommitmentIterator) All() iter.Seq2[*computepb.Commitment, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*CommitmentIterator) Next
func (it *CommitmentIterator) Next() (*computepb.Commitment, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*CommitmentIterator) PageInfo
func (it *CommitmentIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
CommitmentsScopedListPair
type CommitmentsScopedListPair struct {
Key string
Value *computepb.CommitmentsScopedList
}
CommitmentsScopedListPair is a holder type for string/*computepb.CommitmentsScopedList map entries
CommitmentsScopedListPairIterator
type CommitmentsScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []CommitmentsScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
CommitmentsScopedListPairIterator manages a stream of CommitmentsScopedListPair.
func (*CommitmentsScopedListPairIterator) All
func (it *CommitmentsScopedListPairIterator) All() iter.Seq2[CommitmentsScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*CommitmentsScopedListPairIterator) Next
func (it *CommitmentsScopedListPairIterator) Next() (CommitmentsScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*CommitmentsScopedListPairIterator) PageInfo
func (it *CommitmentsScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
DiskIterator
type DiskIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.Disk, nextPageToken string, err error)
// contains filtered or unexported fields
}
DiskIterator manages a stream of *computepb.Disk.
func (*DiskIterator) All
func (it *DiskIterator) All() iter.Seq2[*computepb.Disk, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*DiskIterator) Next
func (it *DiskIterator) Next() (*computepb.Disk, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*DiskIterator) PageInfo
func (it *DiskIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
DiskTypeIterator
type DiskTypeIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.DiskType, nextPageToken string, err error)
// contains filtered or unexported fields
}
DiskTypeIterator manages a stream of *computepb.DiskType.
func (*DiskTypeIterator) All
func (it *DiskTypeIterator) All() iter.Seq2[*computepb.DiskType, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*DiskTypeIterator) Next
func (it *DiskTypeIterator) Next() (*computepb.DiskType, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*DiskTypeIterator) PageInfo
func (it *DiskTypeIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
DiskTypesCallOptions
type DiskTypesCallOptions struct {
AggregatedList []gax.CallOption
Get []gax.CallOption
List []gax.CallOption
}
DiskTypesCallOptions contains the retry settings for each method of DiskTypesClient.
DiskTypesClient
type DiskTypesClient struct {
// The call options for this service.
CallOptions *DiskTypesCallOptions
// contains filtered or unexported fields
}
DiskTypesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The DiskTypes API.
func NewDiskTypesRESTClient
func NewDiskTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*DiskTypesClient, error)
NewDiskTypesRESTClient creates a new disk types rest client.
The DiskTypes API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDiskTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*DiskTypesClient) AggregatedList
func (c *DiskTypesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListDiskTypesRequest, opts ...gax.CallOption) *DiskTypesScopedListPairIterator
AggregatedList retrieves an aggregated list of disk types. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDiskTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListDiskTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListDiskTypesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.DiskTypeAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDiskTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListDiskTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListDiskTypesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*DiskTypesClient) Close
func (c *DiskTypesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*DiskTypesClient) Connection (deprecated)
func (c *DiskTypesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*DiskTypesClient) Get
func (c *DiskTypesClient) Get(ctx context.Context, req *computepb.GetDiskTypeRequest, opts ...gax.CallOption) (*computepb.DiskType, error)
Get returns the specified disk type.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDiskTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetDiskTypeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetDiskTypeRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DiskTypesClient) List
func (c *DiskTypesClient) List(ctx context.Context, req *computepb.ListDiskTypesRequest, opts ...gax.CallOption) *DiskTypeIterator
List retrieves a list of disk types available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDiskTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListDiskTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListDiskTypesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.DiskTypeList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDiskTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListDiskTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListDiskTypesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
DiskTypesScopedListPair
type DiskTypesScopedListPair struct {
Key string
Value *computepb.DiskTypesScopedList
}
DiskTypesScopedListPair is a holder type for string/*computepb.DiskTypesScopedList map entries
DiskTypesScopedListPairIterator
type DiskTypesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []DiskTypesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
DiskTypesScopedListPairIterator manages a stream of DiskTypesScopedListPair.
func (*DiskTypesScopedListPairIterator) All
func (it *DiskTypesScopedListPairIterator) All() iter.Seq2[DiskTypesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*DiskTypesScopedListPairIterator) Next
func (it *DiskTypesScopedListPairIterator) Next() (DiskTypesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*DiskTypesScopedListPairIterator) PageInfo
func (it *DiskTypesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
DisksCallOptions
type DisksCallOptions struct {
AddResourcePolicies []gax.CallOption
AggregatedList []gax.CallOption
BulkInsert []gax.CallOption
CreateSnapshot []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
RemoveResourcePolicies []gax.CallOption
Resize []gax.CallOption
SetIamPolicy []gax.CallOption
SetLabels []gax.CallOption
StartAsyncReplication []gax.CallOption
StopAsyncReplication []gax.CallOption
StopGroupAsyncReplication []gax.CallOption
TestIamPermissions []gax.CallOption
Update []gax.CallOption
}
DisksCallOptions contains the retry settings for each method of DisksClient.
DisksClient
type DisksClient struct {
// The call options for this service.
CallOptions *DisksCallOptions
// contains filtered or unexported fields
}
DisksClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Disks API.
func NewDisksRESTClient
func NewDisksRESTClient(ctx context.Context, opts ...option.ClientOption) (*DisksClient, error)
NewDisksRESTClient creates a new disks rest client.
The Disks API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*DisksClient) AddResourcePolicies
func (c *DisksClient) AddResourcePolicies(ctx context.Context, req *computepb.AddResourcePoliciesDiskRequest, opts ...gax.CallOption) (*Operation, error)
AddResourcePolicies adds existing resource policies to a disk. You can only add one policy which will be applied to this disk for scheduling snapshot creation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddResourcePoliciesDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddResourcePoliciesDiskRequest.
}
op, err := c.AddResourcePolicies(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) AggregatedList
func (c *DisksClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListDisksRequest, opts ...gax.CallOption) *DisksScopedListPairIterator
AggregatedList retrieves an aggregated list of persistent disks. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListDisksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListDisksRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.DiskAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListDisksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListDisksRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*DisksClient) BulkInsert
func (c *DisksClient) BulkInsert(ctx context.Context, req *computepb.BulkInsertDiskRequest, opts ...gax.CallOption) (*Operation, error)
BulkInsert bulk create a set of disks.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.BulkInsertDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#BulkInsertDiskRequest.
}
op, err := c.BulkInsert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) Close
func (c *DisksClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*DisksClient) Connection (deprecated)
func (c *DisksClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*DisksClient) CreateSnapshot
func (c *DisksClient) CreateSnapshot(ctx context.Context, req *computepb.CreateSnapshotDiskRequest, opts ...gax.CallOption) (*Operation, error)
CreateSnapshot creates a snapshot of a specified persistent disk. For regular snapshot creation, consider using snapshots.insert instead, as that method supports more features, such as creating snapshots in a project different from the source disk project.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.CreateSnapshotDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#CreateSnapshotDiskRequest.
}
op, err := c.CreateSnapshot(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) Delete
func (c *DisksClient) Delete(ctx context.Context, req *computepb.DeleteDiskRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified persistent disk. Deleting a disk removes its data permanently and is irreversible. However, deleting a disk does not delete any snapshots previously made from the disk. You must separately delete snapshots.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteDiskRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) Get
func (c *DisksClient) Get(ctx context.Context, req *computepb.GetDiskRequest, opts ...gax.CallOption) (*computepb.Disk, error)
Get returns the specified persistent disk.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetDiskRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DisksClient) GetIamPolicy
func (c *DisksClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyDiskRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyDiskRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DisksClient) Insert
func (c *DisksClient) Insert(ctx context.Context, req *computepb.InsertDiskRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a persistent disk in the specified project using the data in the request. You can create a disk from a source (sourceImage, sourceSnapshot, or sourceDisk) or create an empty 500 GB data disk by omitting all properties. You can also create a disk that is larger than the default size by specifying the sizeGb property.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertDiskRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) List
func (c *DisksClient) List(ctx context.Context, req *computepb.ListDisksRequest, opts ...gax.CallOption) *DiskIterator
List retrieves a list of persistent disks contained within the specified zone.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListDisksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListDisksRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.DiskList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListDisksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListDisksRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*DisksClient) RemoveResourcePolicies
func (c *DisksClient) RemoveResourcePolicies(ctx context.Context, req *computepb.RemoveResourcePoliciesDiskRequest, opts ...gax.CallOption) (*Operation, error)
RemoveResourcePolicies removes resource policies from a disk.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.RemoveResourcePoliciesDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#RemoveResourcePoliciesDiskRequest.
}
op, err := c.RemoveResourcePolicies(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) Resize
func (c *DisksClient) Resize(ctx context.Context, req *computepb.ResizeDiskRequest, opts ...gax.CallOption) (*Operation, error)
Resize resizes the specified persistent disk. You can only increase the size of the disk.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ResizeDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ResizeDiskRequest.
}
op, err := c.Resize(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) SetIamPolicy
func (c *DisksClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyDiskRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyDiskRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DisksClient) SetLabels
func (c *DisksClient) SetLabels(ctx context.Context, req *computepb.SetLabelsDiskRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on a disk. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsDiskRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) StartAsyncReplication
func (c *DisksClient) StartAsyncReplication(ctx context.Context, req *computepb.StartAsyncReplicationDiskRequest, opts ...gax.CallOption) (*Operation, error)
StartAsyncReplication starts asynchronous replication. Must be invoked on the primary disk.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.StartAsyncReplicationDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#StartAsyncReplicationDiskRequest.
}
op, err := c.StartAsyncReplication(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) StopAsyncReplication
func (c *DisksClient) StopAsyncReplication(ctx context.Context, req *computepb.StopAsyncReplicationDiskRequest, opts ...gax.CallOption) (*Operation, error)
StopAsyncReplication stops asynchronous replication. Can be invoked either on the primary or on the secondary disk.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.StopAsyncReplicationDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#StopAsyncReplicationDiskRequest.
}
op, err := c.StopAsyncReplication(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) StopGroupAsyncReplication
func (c *DisksClient) StopGroupAsyncReplication(ctx context.Context, req *computepb.StopGroupAsyncReplicationDiskRequest, opts ...gax.CallOption) (*Operation, error)
StopGroupAsyncReplication stops asynchronous replication for a consistency group of disks. Can be invoked either in the primary or secondary scope.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.StopGroupAsyncReplicationDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#StopGroupAsyncReplicationDiskRequest.
}
op, err := c.StopGroupAsyncReplication(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*DisksClient) TestIamPermissions
func (c *DisksClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsDiskRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsDiskRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*DisksClient) Update
func (c *DisksClient) Update(ctx context.Context, req *computepb.UpdateDiskRequest, opts ...gax.CallOption) (*Operation, error)
Update updates the specified disk with the data included in the request. The update is performed only on selected fields included as part of update-mask. Only the following fields can be modified: user_license.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewDisksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateDiskRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateDiskRequest.
}
op, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
DisksScopedListPair
type DisksScopedListPair struct {
Key string
Value *computepb.DisksScopedList
}
DisksScopedListPair is a holder type for string/*computepb.DisksScopedList map entries
DisksScopedListPairIterator
type DisksScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []DisksScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
DisksScopedListPairIterator manages a stream of DisksScopedListPair.
func (*DisksScopedListPairIterator) All
func (it *DisksScopedListPairIterator) All() iter.Seq2[DisksScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*DisksScopedListPairIterator) Next
func (it *DisksScopedListPairIterator) Next() (DisksScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*DisksScopedListPairIterator) PageInfo
func (it *DisksScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ExchangedPeeringRouteIterator
type ExchangedPeeringRouteIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.ExchangedPeeringRoute, nextPageToken string, err error)
// contains filtered or unexported fields
}
ExchangedPeeringRouteIterator manages a stream of *computepb.ExchangedPeeringRoute.
func (*ExchangedPeeringRouteIterator) All
func (it *ExchangedPeeringRouteIterator) All() iter.Seq2[*computepb.ExchangedPeeringRoute, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ExchangedPeeringRouteIterator) Next
func (it *ExchangedPeeringRouteIterator) Next() (*computepb.ExchangedPeeringRoute, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ExchangedPeeringRouteIterator) PageInfo
func (it *ExchangedPeeringRouteIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ExternalVpnGatewayIterator
type ExternalVpnGatewayIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.ExternalVpnGateway, nextPageToken string, err error)
// contains filtered or unexported fields
}
ExternalVpnGatewayIterator manages a stream of *computepb.ExternalVpnGateway.
func (*ExternalVpnGatewayIterator) All
func (it *ExternalVpnGatewayIterator) All() iter.Seq2[*computepb.ExternalVpnGateway, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ExternalVpnGatewayIterator) Next
func (it *ExternalVpnGatewayIterator) Next() (*computepb.ExternalVpnGateway, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ExternalVpnGatewayIterator) PageInfo
func (it *ExternalVpnGatewayIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ExternalVpnGatewaysCallOptions
type ExternalVpnGatewaysCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
SetLabels []gax.CallOption
TestIamPermissions []gax.CallOption
}
ExternalVpnGatewaysCallOptions contains the retry settings for each method of ExternalVpnGatewaysClient.
ExternalVpnGatewaysClient
type ExternalVpnGatewaysClient struct {
// The call options for this service.
CallOptions *ExternalVpnGatewaysCallOptions
// contains filtered or unexported fields
}
ExternalVpnGatewaysClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The ExternalVpnGateways API.
func NewExternalVpnGatewaysRESTClient
func NewExternalVpnGatewaysRESTClient(ctx context.Context, opts ...option.ClientOption) (*ExternalVpnGatewaysClient, error)
NewExternalVpnGatewaysRESTClient creates a new external vpn gateways rest client.
The ExternalVpnGateways API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewExternalVpnGatewaysRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*ExternalVpnGatewaysClient) Close
func (c *ExternalVpnGatewaysClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ExternalVpnGatewaysClient) Connection (deprecated)
func (c *ExternalVpnGatewaysClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*ExternalVpnGatewaysClient) Delete
func (c *ExternalVpnGatewaysClient) Delete(ctx context.Context, req *computepb.DeleteExternalVpnGatewayRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified externalVpnGateway.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewExternalVpnGatewaysRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteExternalVpnGatewayRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteExternalVpnGatewayRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ExternalVpnGatewaysClient) Get
func (c *ExternalVpnGatewaysClient) Get(ctx context.Context, req *computepb.GetExternalVpnGatewayRequest, opts ...gax.CallOption) (*computepb.ExternalVpnGateway, error)
Get returns the specified externalVpnGateway. Get a list of available externalVpnGateways by making a list() request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewExternalVpnGatewaysRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetExternalVpnGatewayRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetExternalVpnGatewayRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*ExternalVpnGatewaysClient) Insert
func (c *ExternalVpnGatewaysClient) Insert(ctx context.Context, req *computepb.InsertExternalVpnGatewayRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a ExternalVpnGateway in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewExternalVpnGatewaysRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertExternalVpnGatewayRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertExternalVpnGatewayRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ExternalVpnGatewaysClient) List
func (c *ExternalVpnGatewaysClient) List(ctx context.Context, req *computepb.ListExternalVpnGatewaysRequest, opts ...gax.CallOption) *ExternalVpnGatewayIterator
List retrieves the list of ExternalVpnGateway available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewExternalVpnGatewaysRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListExternalVpnGatewaysRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListExternalVpnGatewaysRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.ExternalVpnGatewayList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewExternalVpnGatewaysRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListExternalVpnGatewaysRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListExternalVpnGatewaysRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*ExternalVpnGatewaysClient) SetLabels
func (c *ExternalVpnGatewaysClient) SetLabels(ctx context.Context, req *computepb.SetLabelsExternalVpnGatewayRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on an ExternalVpnGateway. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewExternalVpnGatewaysRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsExternalVpnGatewayRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsExternalVpnGatewayRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ExternalVpnGatewaysClient) TestIamPermissions
func (c *ExternalVpnGatewaysClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsExternalVpnGatewayRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewExternalVpnGatewaysRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsExternalVpnGatewayRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsExternalVpnGatewayRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
FirewallIterator
type FirewallIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.Firewall, nextPageToken string, err error)
// contains filtered or unexported fields
}
FirewallIterator manages a stream of *computepb.Firewall.
func (*FirewallIterator) All
func (it *FirewallIterator) All() iter.Seq2[*computepb.Firewall, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*FirewallIterator) Next
func (it *FirewallIterator) Next() (*computepb.Firewall, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*FirewallIterator) PageInfo
func (it *FirewallIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
FirewallPoliciesCallOptions
type FirewallPoliciesCallOptions struct {
AddAssociation []gax.CallOption
AddRule []gax.CallOption
CloneRules []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetAssociation []gax.CallOption
GetIamPolicy []gax.CallOption
GetRule []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListAssociations []gax.CallOption
Move []gax.CallOption
Patch []gax.CallOption
PatchRule []gax.CallOption
RemoveAssociation []gax.CallOption
RemoveRule []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
FirewallPoliciesCallOptions contains the retry settings for each method of FirewallPoliciesClient.
FirewallPoliciesClient
type FirewallPoliciesClient struct {
// The call options for this service.
CallOptions *FirewallPoliciesCallOptions
// contains filtered or unexported fields
}
FirewallPoliciesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The FirewallPolicies API.
func NewFirewallPoliciesRESTClient
func NewFirewallPoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) (*FirewallPoliciesClient, error)
NewFirewallPoliciesRESTClient creates a new firewall policies rest client.
The FirewallPolicies API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*FirewallPoliciesClient) AddAssociation
func (c *FirewallPoliciesClient) AddAssociation(ctx context.Context, req *computepb.AddAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
AddAssociation inserts an association for the specified firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddAssociationFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddAssociationFirewallPolicyRequest.
}
op, err := c.AddAssociation(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) AddRule
func (c *FirewallPoliciesClient) AddRule(ctx context.Context, req *computepb.AddRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
AddRule inserts a rule into a firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddRuleFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddRuleFirewallPolicyRequest.
}
op, err := c.AddRule(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) CloneRules
func (c *FirewallPoliciesClient) CloneRules(ctx context.Context, req *computepb.CloneRulesFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
CloneRules copies rules to the specified firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.CloneRulesFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#CloneRulesFirewallPolicyRequest.
}
op, err := c.CloneRules(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) Close
func (c *FirewallPoliciesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*FirewallPoliciesClient) Connection (deprecated)
func (c *FirewallPoliciesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*FirewallPoliciesClient) Delete
func (c *FirewallPoliciesClient) Delete(ctx context.Context, req *computepb.DeleteFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteFirewallPolicyRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) Get
func (c *FirewallPoliciesClient) Get(ctx context.Context, req *computepb.GetFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicy, error)
Get returns the specified firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetFirewallPolicyRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*FirewallPoliciesClient) GetAssociation
func (c *FirewallPoliciesClient) GetAssociation(ctx context.Context, req *computepb.GetAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error)
GetAssociation gets an association with the specified name.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetAssociationFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetAssociationFirewallPolicyRequest.
}
resp, err := c.GetAssociation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*FirewallPoliciesClient) GetIamPolicy
func (c *FirewallPoliciesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyFirewallPolicyRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*FirewallPoliciesClient) GetRule
func (c *FirewallPoliciesClient) GetRule(ctx context.Context, req *computepb.GetRuleFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error)
GetRule gets a rule of the specified priority.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetRuleFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetRuleFirewallPolicyRequest.
}
resp, err := c.GetRule(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*FirewallPoliciesClient) Insert
func (c *FirewallPoliciesClient) Insert(ctx context.Context, req *computepb.InsertFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a new policy in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertFirewallPolicyRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) List
func (c *FirewallPoliciesClient) List(ctx context.Context, req *computepb.ListFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPolicyIterator
List lists all the policies that have been configured for the specified folder or organization.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListFirewallPoliciesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListFirewallPoliciesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.FirewallPolicyList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListFirewallPoliciesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListFirewallPoliciesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*FirewallPoliciesClient) ListAssociations
func (c *FirewallPoliciesClient) ListAssociations(ctx context.Context, req *computepb.ListAssociationsFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPoliciesListAssociationsResponse, error)
ListAssociations lists associations of a specified target, i.e., organization or folder.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListAssociationsFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListAssociationsFirewallPolicyRequest.
}
resp, err := c.ListAssociations(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*FirewallPoliciesClient) Move
func (c *FirewallPoliciesClient) Move(ctx context.Context, req *computepb.MoveFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
Move moves the specified firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.MoveFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#MoveFirewallPolicyRequest.
}
op, err := c.Move(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) Patch
func (c *FirewallPoliciesClient) Patch(ctx context.Context, req *computepb.PatchFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
Patch patches the specified policy with the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchFirewallPolicyRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) PatchRule
func (c *FirewallPoliciesClient) PatchRule(ctx context.Context, req *computepb.PatchRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
PatchRule patches a rule of the specified priority.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchRuleFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchRuleFirewallPolicyRequest.
}
op, err := c.PatchRule(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) RemoveAssociation
func (c *FirewallPoliciesClient) RemoveAssociation(ctx context.Context, req *computepb.RemoveAssociationFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
RemoveAssociation removes an association for the specified firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.RemoveAssociationFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#RemoveAssociationFirewallPolicyRequest.
}
op, err := c.RemoveAssociation(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) RemoveRule
func (c *FirewallPoliciesClient) RemoveRule(ctx context.Context, req *computepb.RemoveRuleFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
RemoveRule deletes a rule of the specified priority.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.RemoveRuleFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#RemoveRuleFirewallPolicyRequest.
}
op, err := c.RemoveRule(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallPoliciesClient) SetIamPolicy
func (c *FirewallPoliciesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyFirewallPolicyRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*FirewallPoliciesClient) TestIamPermissions
func (c *FirewallPoliciesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsFirewallPolicyRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
FirewallPoliciesScopedListPair
type FirewallPoliciesScopedListPair struct {
Key string
Value *computepb.FirewallPoliciesScopedList
}
FirewallPoliciesScopedListPair is a holder type for string/*computepb.FirewallPoliciesScopedList map entries
FirewallPoliciesScopedListPairIterator
type FirewallPoliciesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []FirewallPoliciesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
FirewallPoliciesScopedListPairIterator manages a stream of FirewallPoliciesScopedListPair.
func (*FirewallPoliciesScopedListPairIterator) All
func (it *FirewallPoliciesScopedListPairIterator) All() iter.Seq2[FirewallPoliciesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*FirewallPoliciesScopedListPairIterator) Next
func (it *FirewallPoliciesScopedListPairIterator) Next() (FirewallPoliciesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*FirewallPoliciesScopedListPairIterator) PageInfo
func (it *FirewallPoliciesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
FirewallPolicyIterator
type FirewallPolicyIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.FirewallPolicy, nextPageToken string, err error)
// contains filtered or unexported fields
}
FirewallPolicyIterator manages a stream of *computepb.FirewallPolicy.
func (*FirewallPolicyIterator) All
func (it *FirewallPolicyIterator) All() iter.Seq2[*computepb.FirewallPolicy, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*FirewallPolicyIterator) Next
func (it *FirewallPolicyIterator) Next() (*computepb.FirewallPolicy, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*FirewallPolicyIterator) PageInfo
func (it *FirewallPolicyIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
FirewallsCallOptions
type FirewallsCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
Update []gax.CallOption
}
FirewallsCallOptions contains the retry settings for each method of FirewallsClient.
FirewallsClient
type FirewallsClient struct {
// The call options for this service.
CallOptions *FirewallsCallOptions
// contains filtered or unexported fields
}
FirewallsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Firewalls API.
func NewFirewallsRESTClient
func NewFirewallsRESTClient(ctx context.Context, opts ...option.ClientOption) (*FirewallsClient, error)
NewFirewallsRESTClient creates a new firewalls rest client.
The Firewalls API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*FirewallsClient) Close
func (c *FirewallsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*FirewallsClient) Connection (deprecated)
func (c *FirewallsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*FirewallsClient) Delete
func (c *FirewallsClient) Delete(ctx context.Context, req *computepb.DeleteFirewallRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified firewall.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteFirewallRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteFirewallRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallsClient) Get
func (c *FirewallsClient) Get(ctx context.Context, req *computepb.GetFirewallRequest, opts ...gax.CallOption) (*computepb.Firewall, error)
Get returns the specified firewall.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetFirewallRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetFirewallRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*FirewallsClient) Insert
func (c *FirewallsClient) Insert(ctx context.Context, req *computepb.InsertFirewallRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a firewall rule in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertFirewallRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertFirewallRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallsClient) List
func (c *FirewallsClient) List(ctx context.Context, req *computepb.ListFirewallsRequest, opts ...gax.CallOption) *FirewallIterator
List retrieves the list of firewall rules available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListFirewallsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListFirewallsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.FirewallList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListFirewallsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListFirewallsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*FirewallsClient) Patch
func (c *FirewallsClient) Patch(ctx context.Context, req *computepb.PatchFirewallRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates the specified firewall rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchFirewallRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchFirewallRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*FirewallsClient) Update
func (c *FirewallsClient) Update(ctx context.Context, req *computepb.UpdateFirewallRequest, opts ...gax.CallOption) (*Operation, error)
Update updates the specified firewall rule with the data included in the request. Note that all fields will be updated if using PUT, even fields that are not specified. To update individual fields, please use PATCH instead.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewFirewallsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateFirewallRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateFirewallRequest.
}
op, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
ForwardingRuleIterator
type ForwardingRuleIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.ForwardingRule, nextPageToken string, err error)
// contains filtered or unexported fields
}
ForwardingRuleIterator manages a stream of *computepb.ForwardingRule.
func (*ForwardingRuleIterator) All
func (it *ForwardingRuleIterator) All() iter.Seq2[*computepb.ForwardingRule, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ForwardingRuleIterator) Next
func (it *ForwardingRuleIterator) Next() (*computepb.ForwardingRule, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ForwardingRuleIterator) PageInfo
func (it *ForwardingRuleIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ForwardingRulesCallOptions
type ForwardingRulesCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetLabels []gax.CallOption
SetTarget []gax.CallOption
}
ForwardingRulesCallOptions contains the retry settings for each method of ForwardingRulesClient.
ForwardingRulesClient
type ForwardingRulesClient struct {
// The call options for this service.
CallOptions *ForwardingRulesCallOptions
// contains filtered or unexported fields
}
ForwardingRulesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The ForwardingRules API.
func NewForwardingRulesRESTClient
func NewForwardingRulesRESTClient(ctx context.Context, opts ...option.ClientOption) (*ForwardingRulesClient, error)
NewForwardingRulesRESTClient creates a new forwarding rules rest client.
The ForwardingRules API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*ForwardingRulesClient) AggregatedList
func (c *ForwardingRulesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListForwardingRulesRequest, opts ...gax.CallOption) *ForwardingRulesScopedListPairIterator
AggregatedList retrieves an aggregated list of forwarding rules. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListForwardingRulesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListForwardingRulesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.ForwardingRuleAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListForwardingRulesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListForwardingRulesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*ForwardingRulesClient) Close
func (c *ForwardingRulesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ForwardingRulesClient) Connection (deprecated)
func (c *ForwardingRulesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*ForwardingRulesClient) Delete
func (c *ForwardingRulesClient) Delete(ctx context.Context, req *computepb.DeleteForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified ForwardingRule resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteForwardingRuleRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ForwardingRulesClient) Get
func (c *ForwardingRulesClient) Get(ctx context.Context, req *computepb.GetForwardingRuleRequest, opts ...gax.CallOption) (*computepb.ForwardingRule, error)
Get returns the specified ForwardingRule resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetForwardingRuleRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*ForwardingRulesClient) Insert
func (c *ForwardingRulesClient) Insert(ctx context.Context, req *computepb.InsertForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a ForwardingRule resource in the specified project and region using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertForwardingRuleRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ForwardingRulesClient) List
func (c *ForwardingRulesClient) List(ctx context.Context, req *computepb.ListForwardingRulesRequest, opts ...gax.CallOption) *ForwardingRuleIterator
List retrieves a list of ForwardingRule resources available to the specified project and region.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListForwardingRulesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListForwardingRulesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.ForwardingRuleList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListForwardingRulesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListForwardingRulesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*ForwardingRulesClient) Patch
func (c *ForwardingRulesClient) Patch(ctx context.Context, req *computepb.PatchForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchForwardingRuleRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ForwardingRulesClient) SetLabels
func (c *ForwardingRulesClient) SetLabels(ctx context.Context, req *computepb.SetLabelsForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on the specified resource. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsForwardingRuleRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ForwardingRulesClient) SetTarget
func (c *ForwardingRulesClient) SetTarget(ctx context.Context, req *computepb.SetTargetForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
SetTarget changes target URL for forwarding rule. The new target should be of the same type as the old target.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetTargetForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetTargetForwardingRuleRequest.
}
op, err := c.SetTarget(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
ForwardingRulesScopedListPair
type ForwardingRulesScopedListPair struct {
Key string
Value *computepb.ForwardingRulesScopedList
}
ForwardingRulesScopedListPair is a holder type for string/*computepb.ForwardingRulesScopedList map entries
ForwardingRulesScopedListPairIterator
type ForwardingRulesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []ForwardingRulesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
ForwardingRulesScopedListPairIterator manages a stream of ForwardingRulesScopedListPair.
func (*ForwardingRulesScopedListPairIterator) All
func (it *ForwardingRulesScopedListPairIterator) All() iter.Seq2[ForwardingRulesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ForwardingRulesScopedListPairIterator) Next
func (it *ForwardingRulesScopedListPairIterator) Next() (ForwardingRulesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ForwardingRulesScopedListPairIterator) PageInfo
func (it *ForwardingRulesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
GlobalAddressesCallOptions
type GlobalAddressesCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Move []gax.CallOption
SetLabels []gax.CallOption
}
GlobalAddressesCallOptions contains the retry settings for each method of GlobalAddressesClient.
GlobalAddressesClient
type GlobalAddressesClient struct {
// The call options for this service.
CallOptions *GlobalAddressesCallOptions
// contains filtered or unexported fields
}
GlobalAddressesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The GlobalAddresses API.
func NewGlobalAddressesRESTClient
func NewGlobalAddressesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalAddressesClient, error)
NewGlobalAddressesRESTClient creates a new global addresses rest client.
The GlobalAddresses API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*GlobalAddressesClient) Close
func (c *GlobalAddressesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*GlobalAddressesClient) Connection (deprecated)
func (c *GlobalAddressesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*GlobalAddressesClient) Delete
func (c *GlobalAddressesClient) Delete(ctx context.Context, req *computepb.DeleteGlobalAddressRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified address resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteGlobalAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteGlobalAddressRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalAddressesClient) Get
func (c *GlobalAddressesClient) Get(ctx context.Context, req *computepb.GetGlobalAddressRequest, opts ...gax.CallOption) (*computepb.Address, error)
Get returns the specified address resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetGlobalAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetGlobalAddressRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*GlobalAddressesClient) Insert
func (c *GlobalAddressesClient) Insert(ctx context.Context, req *computepb.InsertGlobalAddressRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an address resource in the specified project by using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertGlobalAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertGlobalAddressRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalAddressesClient) List
func (c *GlobalAddressesClient) List(ctx context.Context, req *computepb.ListGlobalAddressesRequest, opts ...gax.CallOption) *AddressIterator
List retrieves a list of global addresses.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalAddressesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalAddressesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.AddressList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalAddressesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalAddressesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*GlobalAddressesClient) Move
func (c *GlobalAddressesClient) Move(ctx context.Context, req *computepb.MoveGlobalAddressRequest, opts ...gax.CallOption) (*Operation, error)
Move moves the specified address resource from one project to another project.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.MoveGlobalAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#MoveGlobalAddressRequest.
}
op, err := c.Move(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalAddressesClient) SetLabels
func (c *GlobalAddressesClient) SetLabels(ctx context.Context, req *computepb.SetLabelsGlobalAddressRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on a GlobalAddress. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalAddressesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsGlobalAddressRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsGlobalAddressRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
GlobalForwardingRulesCallOptions
type GlobalForwardingRulesCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetLabels []gax.CallOption
SetTarget []gax.CallOption
}
GlobalForwardingRulesCallOptions contains the retry settings for each method of GlobalForwardingRulesClient.
GlobalForwardingRulesClient
type GlobalForwardingRulesClient struct {
// The call options for this service.
CallOptions *GlobalForwardingRulesCallOptions
// contains filtered or unexported fields
}
GlobalForwardingRulesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The GlobalForwardingRules API.
func NewGlobalForwardingRulesRESTClient
func NewGlobalForwardingRulesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalForwardingRulesClient, error)
NewGlobalForwardingRulesRESTClient creates a new global forwarding rules rest client.
The GlobalForwardingRules API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*GlobalForwardingRulesClient) Close
func (c *GlobalForwardingRulesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*GlobalForwardingRulesClient) Connection (deprecated)
func (c *GlobalForwardingRulesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*GlobalForwardingRulesClient) Delete
func (c *GlobalForwardingRulesClient) Delete(ctx context.Context, req *computepb.DeleteGlobalForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified GlobalForwardingRule resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteGlobalForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteGlobalForwardingRuleRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalForwardingRulesClient) Get
func (c *GlobalForwardingRulesClient) Get(ctx context.Context, req *computepb.GetGlobalForwardingRuleRequest, opts ...gax.CallOption) (*computepb.ForwardingRule, error)
Get returns the specified GlobalForwardingRule resource. Gets a list of available forwarding rules by making a list() request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetGlobalForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetGlobalForwardingRuleRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*GlobalForwardingRulesClient) Insert
func (c *GlobalForwardingRulesClient) Insert(ctx context.Context, req *computepb.InsertGlobalForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a GlobalForwardingRule resource in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertGlobalForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertGlobalForwardingRuleRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalForwardingRulesClient) List
func (c *GlobalForwardingRulesClient) List(ctx context.Context, req *computepb.ListGlobalForwardingRulesRequest, opts ...gax.CallOption) *ForwardingRuleIterator
List retrieves a list of GlobalForwardingRule resources available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalForwardingRulesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalForwardingRulesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.ForwardingRuleList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalForwardingRulesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalForwardingRulesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*GlobalForwardingRulesClient) Patch
func (c *GlobalForwardingRulesClient) Patch(ctx context.Context, req *computepb.PatchGlobalForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates the specified forwarding rule with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. Currently, you can only patch the network_tier field.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchGlobalForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchGlobalForwardingRuleRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalForwardingRulesClient) SetLabels
func (c *GlobalForwardingRulesClient) SetLabels(ctx context.Context, req *computepb.SetLabelsGlobalForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on the specified resource. To learn more about labels, read the Labeling resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsGlobalForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsGlobalForwardingRuleRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalForwardingRulesClient) SetTarget
func (c *GlobalForwardingRulesClient) SetTarget(ctx context.Context, req *computepb.SetTargetGlobalForwardingRuleRequest, opts ...gax.CallOption) (*Operation, error)
SetTarget changes target URL for the GlobalForwardingRule resource. The new target should be of the same type as the old target.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalForwardingRulesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetTargetGlobalForwardingRuleRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetTargetGlobalForwardingRuleRequest.
}
op, err := c.SetTarget(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
GlobalNetworkEndpointGroupsCallOptions
type GlobalNetworkEndpointGroupsCallOptions struct {
AttachNetworkEndpoints []gax.CallOption
Delete []gax.CallOption
DetachNetworkEndpoints []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListNetworkEndpoints []gax.CallOption
}
GlobalNetworkEndpointGroupsCallOptions contains the retry settings for each method of GlobalNetworkEndpointGroupsClient.
GlobalNetworkEndpointGroupsClient
type GlobalNetworkEndpointGroupsClient struct {
// The call options for this service.
CallOptions *GlobalNetworkEndpointGroupsCallOptions
// contains filtered or unexported fields
}
GlobalNetworkEndpointGroupsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The GlobalNetworkEndpointGroups API.
func NewGlobalNetworkEndpointGroupsRESTClient
func NewGlobalNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalNetworkEndpointGroupsClient, error)
NewGlobalNetworkEndpointGroupsRESTClient creates a new global network endpoint groups rest client.
The GlobalNetworkEndpointGroups API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*GlobalNetworkEndpointGroupsClient) AttachNetworkEndpoints
func (c *GlobalNetworkEndpointGroupsClient) AttachNetworkEndpoints(ctx context.Context, req *computepb.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest, opts ...gax.CallOption) (*Operation, error)
AttachNetworkEndpoints attach a network endpoint to the specified network endpoint group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AttachNetworkEndpointsGlobalNetworkEndpointGroupRequest.
}
op, err := c.AttachNetworkEndpoints(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalNetworkEndpointGroupsClient) Close
func (c *GlobalNetworkEndpointGroupsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*GlobalNetworkEndpointGroupsClient) Connection (deprecated)
func (c *GlobalNetworkEndpointGroupsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*GlobalNetworkEndpointGroupsClient) Delete
func (c *GlobalNetworkEndpointGroupsClient) Delete(ctx context.Context, req *computepb.DeleteGlobalNetworkEndpointGroupRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified network endpoint group.Note that the NEG cannot be deleted if there are backend services referencing it.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteGlobalNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteGlobalNetworkEndpointGroupRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalNetworkEndpointGroupsClient) DetachNetworkEndpoints
func (c *GlobalNetworkEndpointGroupsClient) DetachNetworkEndpoints(ctx context.Context, req *computepb.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest, opts ...gax.CallOption) (*Operation, error)
DetachNetworkEndpoints detach the network endpoint from the specified network endpoint group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DetachNetworkEndpointsGlobalNetworkEndpointGroupRequest.
}
op, err := c.DetachNetworkEndpoints(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalNetworkEndpointGroupsClient) Get
func (c *GlobalNetworkEndpointGroupsClient) Get(ctx context.Context, req *computepb.GetGlobalNetworkEndpointGroupRequest, opts ...gax.CallOption) (*computepb.NetworkEndpointGroup, error)
Get returns the specified network endpoint group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetGlobalNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetGlobalNetworkEndpointGroupRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*GlobalNetworkEndpointGroupsClient) Insert
func (c *GlobalNetworkEndpointGroupsClient) Insert(ctx context.Context, req *computepb.InsertGlobalNetworkEndpointGroupRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a network endpoint group in the specified project using the parameters that are included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertGlobalNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertGlobalNetworkEndpointGroupRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalNetworkEndpointGroupsClient) List
func (c *GlobalNetworkEndpointGroupsClient) List(ctx context.Context, req *computepb.ListGlobalNetworkEndpointGroupsRequest, opts ...gax.CallOption) *NetworkEndpointGroupIterator
List retrieves the list of network endpoint groups that are located in the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalNetworkEndpointGroupsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkEndpointGroupList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalNetworkEndpointGroupsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*GlobalNetworkEndpointGroupsClient) ListNetworkEndpoints
func (c *GlobalNetworkEndpointGroupsClient) ListNetworkEndpoints(ctx context.Context, req *computepb.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest, opts ...gax.CallOption) *NetworkEndpointWithHealthStatusIterator
ListNetworkEndpoints lists the network endpoints in the specified network endpoint group.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest.
}
it := c.ListNetworkEndpoints(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkEndpointGroupsListNetworkEndpoints)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListNetworkEndpointsGlobalNetworkEndpointGroupsRequest.
}
for resp, err := range c.ListNetworkEndpoints(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
GlobalOperationsCallOptions
type GlobalOperationsCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
List []gax.CallOption
Wait []gax.CallOption
}
GlobalOperationsCallOptions contains the retry settings for each method of GlobalOperationsClient.
GlobalOperationsClient
type GlobalOperationsClient struct {
// The call options for this service.
CallOptions *GlobalOperationsCallOptions
// contains filtered or unexported fields
}
GlobalOperationsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The GlobalOperations API.
func NewGlobalOperationsRESTClient
func NewGlobalOperationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalOperationsClient, error)
NewGlobalOperationsRESTClient creates a new global operations rest client.
The GlobalOperations API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*GlobalOperationsClient) AggregatedList
func (c *GlobalOperationsClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListGlobalOperationsRequest, opts ...gax.CallOption) *OperationsScopedListPairIterator
AggregatedList retrieves an aggregated list of all operations. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListGlobalOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListGlobalOperationsRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.OperationAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListGlobalOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListGlobalOperationsRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*GlobalOperationsClient) Close
func (c *GlobalOperationsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*GlobalOperationsClient) Connection (deprecated)
func (c *GlobalOperationsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*GlobalOperationsClient) Delete
func (c *GlobalOperationsClient) Delete(ctx context.Context, req *computepb.DeleteGlobalOperationRequest, opts ...gax.CallOption) (*computepb.DeleteGlobalOperationResponse, error)
Delete deletes the specified Operations resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteGlobalOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteGlobalOperationRequest.
}
resp, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*GlobalOperationsClient) Get
func (c *GlobalOperationsClient) Get(ctx context.Context, req *computepb.GetGlobalOperationRequest, opts ...gax.CallOption) (*computepb.Operation, error)
Get retrieves the specified Operations resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetGlobalOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetGlobalOperationRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*GlobalOperationsClient) List
func (c *GlobalOperationsClient) List(ctx context.Context, req *computepb.ListGlobalOperationsRequest, opts ...gax.CallOption) *OperationIterator
List retrieves a list of Operation resources contained within the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalOperationsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.OperationList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalOperationsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*GlobalOperationsClient) Wait
func (c *GlobalOperationsClient) Wait(ctx context.Context, req *computepb.WaitGlobalOperationRequest, opts ...gax.CallOption) (*computepb.Operation, error)
Wait waits for the specified Operation resource to return as DONE or for the request to approach the 2 minute deadline, and retrieves the specified Operation resource. This method differs from the GET method in that it waits for no more than the default deadline (2 minutes) and then returns the current state of the operation, which might be DONE or still in progress. This method is called on a best-effort basis. Specifically: - In uncommon cases, when the server is overloaded, the request might return before the default deadline is reached, or might return after zero seconds. - If the default deadline is reached, there is no guarantee that the operation is actually done when the method returns. Be prepared to retry if the operation is not DONE.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.WaitGlobalOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#WaitGlobalOperationRequest.
}
resp, err := c.Wait(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
GlobalOrganizationOperationsCallOptions
type GlobalOrganizationOperationsCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
List []gax.CallOption
}
GlobalOrganizationOperationsCallOptions contains the retry settings for each method of GlobalOrganizationOperationsClient.
GlobalOrganizationOperationsClient
type GlobalOrganizationOperationsClient struct {
// The call options for this service.
CallOptions *GlobalOrganizationOperationsCallOptions
// contains filtered or unexported fields
}
GlobalOrganizationOperationsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The GlobalOrganizationOperations API.
func NewGlobalOrganizationOperationsRESTClient
func NewGlobalOrganizationOperationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalOrganizationOperationsClient, error)
NewGlobalOrganizationOperationsRESTClient creates a new global organization operations rest client.
The GlobalOrganizationOperations API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOrganizationOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*GlobalOrganizationOperationsClient) Close
func (c *GlobalOrganizationOperationsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*GlobalOrganizationOperationsClient) Connection (deprecated)
func (c *GlobalOrganizationOperationsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*GlobalOrganizationOperationsClient) Delete
func (c *GlobalOrganizationOperationsClient) Delete(ctx context.Context, req *computepb.DeleteGlobalOrganizationOperationRequest, opts ...gax.CallOption) (*computepb.DeleteGlobalOrganizationOperationResponse, error)
Delete deletes the specified Operations resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOrganizationOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteGlobalOrganizationOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteGlobalOrganizationOperationRequest.
}
resp, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*GlobalOrganizationOperationsClient) Get
func (c *GlobalOrganizationOperationsClient) Get(ctx context.Context, req *computepb.GetGlobalOrganizationOperationRequest, opts ...gax.CallOption) (*computepb.Operation, error)
Get retrieves the specified Operations resource. Gets a list of operations by making a list() request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOrganizationOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetGlobalOrganizationOperationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetGlobalOrganizationOperationRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*GlobalOrganizationOperationsClient) List
func (c *GlobalOrganizationOperationsClient) List(ctx context.Context, req *computepb.ListGlobalOrganizationOperationsRequest, opts ...gax.CallOption) *OperationIterator
List retrieves a list of Operation resources contained within the specified organization.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOrganizationOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalOrganizationOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalOrganizationOperationsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.OperationList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalOrganizationOperationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalOrganizationOperationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalOrganizationOperationsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
GlobalPublicDelegatedPrefixesCallOptions
type GlobalPublicDelegatedPrefixesCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
}
GlobalPublicDelegatedPrefixesCallOptions contains the retry settings for each method of GlobalPublicDelegatedPrefixesClient.
GlobalPublicDelegatedPrefixesClient
type GlobalPublicDelegatedPrefixesClient struct {
// The call options for this service.
CallOptions *GlobalPublicDelegatedPrefixesCallOptions
// contains filtered or unexported fields
}
GlobalPublicDelegatedPrefixesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The GlobalPublicDelegatedPrefixes API.
func NewGlobalPublicDelegatedPrefixesRESTClient
func NewGlobalPublicDelegatedPrefixesRESTClient(ctx context.Context, opts ...option.ClientOption) (*GlobalPublicDelegatedPrefixesClient, error)
NewGlobalPublicDelegatedPrefixesRESTClient creates a new global public delegated prefixes rest client.
The GlobalPublicDelegatedPrefixes API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalPublicDelegatedPrefixesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*GlobalPublicDelegatedPrefixesClient) Close
func (c *GlobalPublicDelegatedPrefixesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*GlobalPublicDelegatedPrefixesClient) Connection (deprecated)
func (c *GlobalPublicDelegatedPrefixesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*GlobalPublicDelegatedPrefixesClient) Delete
func (c *GlobalPublicDelegatedPrefixesClient) Delete(ctx context.Context, req *computepb.DeleteGlobalPublicDelegatedPrefixeRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified global PublicDelegatedPrefix.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalPublicDelegatedPrefixesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteGlobalPublicDelegatedPrefixeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteGlobalPublicDelegatedPrefixeRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalPublicDelegatedPrefixesClient) Get
func (c *GlobalPublicDelegatedPrefixesClient) Get(ctx context.Context, req *computepb.GetGlobalPublicDelegatedPrefixeRequest, opts ...gax.CallOption) (*computepb.PublicDelegatedPrefix, error)
Get returns the specified global PublicDelegatedPrefix resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalPublicDelegatedPrefixesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetGlobalPublicDelegatedPrefixeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetGlobalPublicDelegatedPrefixeRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*GlobalPublicDelegatedPrefixesClient) Insert
func (c *GlobalPublicDelegatedPrefixesClient) Insert(ctx context.Context, req *computepb.InsertGlobalPublicDelegatedPrefixeRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a global PublicDelegatedPrefix in the specified project using the parameters that are included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalPublicDelegatedPrefixesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertGlobalPublicDelegatedPrefixeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertGlobalPublicDelegatedPrefixeRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*GlobalPublicDelegatedPrefixesClient) List
func (c *GlobalPublicDelegatedPrefixesClient) List(ctx context.Context, req *computepb.ListGlobalPublicDelegatedPrefixesRequest, opts ...gax.CallOption) *PublicDelegatedPrefixIterator
List lists the global PublicDelegatedPrefixes for a project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalPublicDelegatedPrefixesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalPublicDelegatedPrefixesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalPublicDelegatedPrefixesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.PublicDelegatedPrefixList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalPublicDelegatedPrefixesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListGlobalPublicDelegatedPrefixesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListGlobalPublicDelegatedPrefixesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*GlobalPublicDelegatedPrefixesClient) Patch
func (c *GlobalPublicDelegatedPrefixesClient) Patch(ctx context.Context, req *computepb.PatchGlobalPublicDelegatedPrefixeRequest, opts ...gax.CallOption) (*Operation, error)
Patch patches the specified global PublicDelegatedPrefix resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewGlobalPublicDelegatedPrefixesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchGlobalPublicDelegatedPrefixeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchGlobalPublicDelegatedPrefixeRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
HealthCheckIterator
type HealthCheckIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.HealthCheck, nextPageToken string, err error)
// contains filtered or unexported fields
}
HealthCheckIterator manages a stream of *computepb.HealthCheck.
func (*HealthCheckIterator) All
func (it *HealthCheckIterator) All() iter.Seq2[*computepb.HealthCheck, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*HealthCheckIterator) Next
func (it *HealthCheckIterator) Next() (*computepb.HealthCheck, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*HealthCheckIterator) PageInfo
func (it *HealthCheckIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
HealthCheckServiceIterator
type HealthCheckServiceIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.HealthCheckService, nextPageToken string, err error)
// contains filtered or unexported fields
}
HealthCheckServiceIterator manages a stream of *computepb.HealthCheckService.
func (*HealthCheckServiceIterator) All
func (it *HealthCheckServiceIterator) All() iter.Seq2[*computepb.HealthCheckService, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*HealthCheckServiceIterator) Next
func (it *HealthCheckServiceIterator) Next() (*computepb.HealthCheckService, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*HealthCheckServiceIterator) PageInfo
func (it *HealthCheckServiceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
HealthChecksCallOptions
type HealthChecksCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
Update []gax.CallOption
}
HealthChecksCallOptions contains the retry settings for each method of HealthChecksClient.
HealthChecksClient
type HealthChecksClient struct {
// The call options for this service.
CallOptions *HealthChecksCallOptions
// contains filtered or unexported fields
}
HealthChecksClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The HealthChecks API.
func NewHealthChecksRESTClient
func NewHealthChecksRESTClient(ctx context.Context, opts ...option.ClientOption) (*HealthChecksClient, error)
NewHealthChecksRESTClient creates a new health checks rest client.
The HealthChecks API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*HealthChecksClient) AggregatedList
func (c *HealthChecksClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListHealthChecksRequest, opts ...gax.CallOption) *HealthChecksScopedListPairIterator
AggregatedList retrieves the list of all HealthCheck resources, regional and global, available to the specified project. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListHealthChecksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListHealthChecksRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.HealthChecksAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListHealthChecksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListHealthChecksRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*HealthChecksClient) Close
func (c *HealthChecksClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*HealthChecksClient) Connection (deprecated)
func (c *HealthChecksClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*HealthChecksClient) Delete
func (c *HealthChecksClient) Delete(ctx context.Context, req *computepb.DeleteHealthCheckRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified HealthCheck resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteHealthCheckRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteHealthCheckRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*HealthChecksClient) Get
func (c *HealthChecksClient) Get(ctx context.Context, req *computepb.GetHealthCheckRequest, opts ...gax.CallOption) (*computepb.HealthCheck, error)
Get returns the specified HealthCheck resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetHealthCheckRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetHealthCheckRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*HealthChecksClient) Insert
func (c *HealthChecksClient) Insert(ctx context.Context, req *computepb.InsertHealthCheckRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a HealthCheck resource in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertHealthCheckRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertHealthCheckRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*HealthChecksClient) List
func (c *HealthChecksClient) List(ctx context.Context, req *computepb.ListHealthChecksRequest, opts ...gax.CallOption) *HealthCheckIterator
List retrieves the list of HealthCheck resources available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListHealthChecksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListHealthChecksRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.HealthCheckList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListHealthChecksRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListHealthChecksRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*HealthChecksClient) Patch
func (c *HealthChecksClient) Patch(ctx context.Context, req *computepb.PatchHealthCheckRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates a HealthCheck resource in the specified project using the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchHealthCheckRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchHealthCheckRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*HealthChecksClient) Update
func (c *HealthChecksClient) Update(ctx context.Context, req *computepb.UpdateHealthCheckRequest, opts ...gax.CallOption) (*Operation, error)
Update updates a HealthCheck resource in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewHealthChecksRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateHealthCheckRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateHealthCheckRequest.
}
op, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
HealthChecksScopedListPair
type HealthChecksScopedListPair struct {
Key string
Value *computepb.HealthChecksScopedList
}
HealthChecksScopedListPair is a holder type for string/*computepb.HealthChecksScopedList map entries
HealthChecksScopedListPairIterator
type HealthChecksScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []HealthChecksScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
HealthChecksScopedListPairIterator manages a stream of HealthChecksScopedListPair.
func (*HealthChecksScopedListPairIterator) All
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*HealthChecksScopedListPairIterator) Next
func (it *HealthChecksScopedListPairIterator) Next() (HealthChecksScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*HealthChecksScopedListPairIterator) PageInfo
func (it *HealthChecksScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ImageFamilyViewsCallOptions
type ImageFamilyViewsCallOptions struct {
Get []gax.CallOption
}
ImageFamilyViewsCallOptions contains the retry settings for each method of ImageFamilyViewsClient.
ImageFamilyViewsClient
type ImageFamilyViewsClient struct {
// The call options for this service.
CallOptions *ImageFamilyViewsCallOptions
// contains filtered or unexported fields
}
ImageFamilyViewsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The ImageFamilyViews API.
func NewImageFamilyViewsRESTClient
func NewImageFamilyViewsRESTClient(ctx context.Context, opts ...option.ClientOption) (*ImageFamilyViewsClient, error)
NewImageFamilyViewsRESTClient creates a new image family views rest client.
The ImageFamilyViews API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImageFamilyViewsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*ImageFamilyViewsClient) Close
func (c *ImageFamilyViewsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ImageFamilyViewsClient) Connection (deprecated)
func (c *ImageFamilyViewsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*ImageFamilyViewsClient) Get
func (c *ImageFamilyViewsClient) Get(ctx context.Context, req *computepb.GetImageFamilyViewRequest, opts ...gax.CallOption) (*computepb.ImageFamilyView, error)
Get returns the latest image that is part of an image family, is not deprecated and is rolled out in the specified zone.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImageFamilyViewsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetImageFamilyViewRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetImageFamilyViewRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
ImageIterator
type ImageIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.Image, nextPageToken string, err error)
// contains filtered or unexported fields
}
ImageIterator manages a stream of *computepb.Image.
func (*ImageIterator) All
func (it *ImageIterator) All() iter.Seq2[*computepb.Image, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ImageIterator) Next
func (it *ImageIterator) Next() (*computepb.Image, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ImageIterator) PageInfo
func (it *ImageIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ImagesCallOptions
type ImagesCallOptions struct {
Delete []gax.CallOption
Deprecate []gax.CallOption
Get []gax.CallOption
GetFromFamily []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetIamPolicy []gax.CallOption
SetLabels []gax.CallOption
TestIamPermissions []gax.CallOption
}
ImagesCallOptions contains the retry settings for each method of ImagesClient.
ImagesClient
type ImagesClient struct {
// The call options for this service.
CallOptions *ImagesCallOptions
// contains filtered or unexported fields
}
ImagesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Images API.
func NewImagesRESTClient
func NewImagesRESTClient(ctx context.Context, opts ...option.ClientOption) (*ImagesClient, error)
NewImagesRESTClient creates a new images rest client.
The Images API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*ImagesClient) Close
func (c *ImagesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*ImagesClient) Connection (deprecated)
func (c *ImagesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*ImagesClient) Delete
func (c *ImagesClient) Delete(ctx context.Context, req *computepb.DeleteImageRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified image.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteImageRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ImagesClient) Deprecate
func (c *ImagesClient) Deprecate(ctx context.Context, req *computepb.DeprecateImageRequest, opts ...gax.CallOption) (*Operation, error)
Deprecate sets the deprecation status of an image. If an empty request body is given, clears the deprecation status instead.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeprecateImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeprecateImageRequest.
}
op, err := c.Deprecate(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ImagesClient) Get
func (c *ImagesClient) Get(ctx context.Context, req *computepb.GetImageRequest, opts ...gax.CallOption) (*computepb.Image, error)
Get returns the specified image.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetImageRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*ImagesClient) GetFromFamily
func (c *ImagesClient) GetFromFamily(ctx context.Context, req *computepb.GetFromFamilyImageRequest, opts ...gax.CallOption) (*computepb.Image, error)
GetFromFamily returns the latest image that is part of an image family and is not deprecated. For more information on image families, see Public image families documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetFromFamilyImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetFromFamilyImageRequest.
}
resp, err := c.GetFromFamily(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*ImagesClient) GetIamPolicy
func (c *ImagesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyImageRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyImageRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*ImagesClient) Insert
func (c *ImagesClient) Insert(ctx context.Context, req *computepb.InsertImageRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an image in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertImageRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ImagesClient) List
func (c *ImagesClient) List(ctx context.Context, req *computepb.ListImagesRequest, opts ...gax.CallOption) *ImageIterator
List retrieves the list of custom images available to the specified project. Custom images are images you create that belong to your project. This method does not get any images that belong to other projects, including publicly-available images, like Debian 8. If you want to get a list of publicly-available images, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListImagesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListImagesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.ImageList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListImagesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListImagesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*ImagesClient) Patch
func (c *ImagesClient) Patch(ctx context.Context, req *computepb.PatchImageRequest, opts ...gax.CallOption) (*Operation, error)
Patch patches the specified image with the data included in the request. Only the following fields can be modified: family, description, deprecation status.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchImageRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ImagesClient) SetIamPolicy
func (c *ImagesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyImageRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyImageRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*ImagesClient) SetLabels
func (c *ImagesClient) SetLabels(ctx context.Context, req *computepb.SetLabelsImageRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on an image. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsImageRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*ImagesClient) TestIamPermissions
func (c *ImagesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsImageRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsImageRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
InstanceGroupIterator
type InstanceGroupIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InstanceGroup, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceGroupIterator manages a stream of *computepb.InstanceGroup.
func (*InstanceGroupIterator) All
func (it *InstanceGroupIterator) All() iter.Seq2[*computepb.InstanceGroup, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceGroupIterator) Next
func (it *InstanceGroupIterator) Next() (*computepb.InstanceGroup, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceGroupIterator) PageInfo
func (it *InstanceGroupIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceGroupManagerIterator
type InstanceGroupManagerIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InstanceGroupManager, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceGroupManagerIterator manages a stream of *computepb.InstanceGroupManager.
func (*InstanceGroupManagerIterator) All
func (it *InstanceGroupManagerIterator) All() iter.Seq2[*computepb.InstanceGroupManager, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceGroupManagerIterator) Next
func (it *InstanceGroupManagerIterator) Next() (*computepb.InstanceGroupManager, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceGroupManagerIterator) PageInfo
func (it *InstanceGroupManagerIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceGroupManagerResizeRequestIterator
type InstanceGroupManagerResizeRequestIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InstanceGroupManagerResizeRequest, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceGroupManagerResizeRequestIterator manages a stream of *computepb.InstanceGroupManagerResizeRequest.
func (*InstanceGroupManagerResizeRequestIterator) All
func (it *InstanceGroupManagerResizeRequestIterator) All() iter.Seq2[*computepb.InstanceGroupManagerResizeRequest, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceGroupManagerResizeRequestIterator) Next
func (it *InstanceGroupManagerResizeRequestIterator) Next() (*computepb.InstanceGroupManagerResizeRequest, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceGroupManagerResizeRequestIterator) PageInfo
func (it *InstanceGroupManagerResizeRequestIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceGroupManagerResizeRequestsCallOptions
type InstanceGroupManagerResizeRequestsCallOptions struct {
Cancel []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
}
InstanceGroupManagerResizeRequestsCallOptions contains the retry settings for each method of InstanceGroupManagerResizeRequestsClient.
InstanceGroupManagerResizeRequestsClient
type InstanceGroupManagerResizeRequestsClient struct {
// The call options for this service.
CallOptions *InstanceGroupManagerResizeRequestsCallOptions
// contains filtered or unexported fields
}
InstanceGroupManagerResizeRequestsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InstanceGroupManagerResizeRequests API.
func NewInstanceGroupManagerResizeRequestsRESTClient
func NewInstanceGroupManagerResizeRequestsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupManagerResizeRequestsClient, error)
NewInstanceGroupManagerResizeRequestsRESTClient creates a new instance group manager resize requests rest client.
The InstanceGroupManagerResizeRequests API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagerResizeRequestsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InstanceGroupManagerResizeRequestsClient) Cancel
func (c *InstanceGroupManagerResizeRequestsClient) Cancel(ctx context.Context, req *computepb.CancelInstanceGroupManagerResizeRequestRequest, opts ...gax.CallOption) (*Operation, error)
Cancel cancels the specified resize request and removes it from the queue. Cancelled resize request does no longer wait for the resources to be provisioned. Cancel is only possible for requests that are accepted in the queue.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagerResizeRequestsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.CancelInstanceGroupManagerResizeRequestRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#CancelInstanceGroupManagerResizeRequestRequest.
}
op, err := c.Cancel(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagerResizeRequestsClient) Close
func (c *InstanceGroupManagerResizeRequestsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InstanceGroupManagerResizeRequestsClient) Connection (deprecated)
func (c *InstanceGroupManagerResizeRequestsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InstanceGroupManagerResizeRequestsClient) Delete
func (c *InstanceGroupManagerResizeRequestsClient) Delete(ctx context.Context, req *computepb.DeleteInstanceGroupManagerResizeRequestRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified, inactive resize request. Requests that are still active cannot be deleted. Deleting request does not delete instances that were provisioned previously.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagerResizeRequestsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInstanceGroupManagerResizeRequestRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInstanceGroupManagerResizeRequestRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagerResizeRequestsClient) Get
func (c *InstanceGroupManagerResizeRequestsClient) Get(ctx context.Context, req *computepb.GetInstanceGroupManagerResizeRequestRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManagerResizeRequest, error)
Get returns all of the details about the specified resize request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagerResizeRequestsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInstanceGroupManagerResizeRequestRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInstanceGroupManagerResizeRequestRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstanceGroupManagerResizeRequestsClient) Insert
func (c *InstanceGroupManagerResizeRequestsClient) Insert(ctx context.Context, req *computepb.InsertInstanceGroupManagerResizeRequestRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a new resize request that starts provisioning VMs immediately or queues VM creation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagerResizeRequestsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertInstanceGroupManagerResizeRequestRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertInstanceGroupManagerResizeRequestRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagerResizeRequestsClient) List
func (c *InstanceGroupManagerResizeRequestsClient) List(ctx context.Context, req *computepb.ListInstanceGroupManagerResizeRequestsRequest, opts ...gax.CallOption) *InstanceGroupManagerResizeRequestIterator
List retrieves a list of resize requests that are contained in the managed instance group.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagerResizeRequestsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstanceGroupManagerResizeRequestsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstanceGroupManagerResizeRequestsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupManagerResizeRequestsListResponse)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagerResizeRequestsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstanceGroupManagerResizeRequestsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstanceGroupManagerResizeRequestsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
InstanceGroupManagersCallOptions
type InstanceGroupManagersCallOptions struct {
AbandonInstances []gax.CallOption
AggregatedList []gax.CallOption
ApplyUpdatesToInstances []gax.CallOption
CreateInstances []gax.CallOption
Delete []gax.CallOption
DeleteInstances []gax.CallOption
DeletePerInstanceConfigs []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListErrors []gax.CallOption
ListManagedInstances []gax.CallOption
ListPerInstanceConfigs []gax.CallOption
Patch []gax.CallOption
PatchPerInstanceConfigs []gax.CallOption
RecreateInstances []gax.CallOption
Resize []gax.CallOption
ResumeInstances []gax.CallOption
SetInstanceTemplate []gax.CallOption
SetTargetPools []gax.CallOption
StartInstances []gax.CallOption
StopInstances []gax.CallOption
SuspendInstances []gax.CallOption
UpdatePerInstanceConfigs []gax.CallOption
}
InstanceGroupManagersCallOptions contains the retry settings for each method of InstanceGroupManagersClient.
InstanceGroupManagersClient
type InstanceGroupManagersClient struct {
// The call options for this service.
CallOptions *InstanceGroupManagersCallOptions
// contains filtered or unexported fields
}
InstanceGroupManagersClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InstanceGroupManagers API.
func NewInstanceGroupManagersRESTClient
func NewInstanceGroupManagersRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupManagersClient, error)
NewInstanceGroupManagersRESTClient creates a new instance group managers rest client.
The InstanceGroupManagers API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InstanceGroupManagersClient) AbandonInstances
func (c *InstanceGroupManagersClient) AbandonInstances(ctx context.Context, req *computepb.AbandonInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
AbandonInstances flags the specified instances to be removed from the managed instance group. Abandoning an instance does not delete the instance, but it does remove the instance from any target pools that are applied by the managed instance group. This method reduces the targetSize of the managed instance group by the number of instances that you abandon. This operation is marked as DONE when the action is scheduled even if the instances have not yet been removed from the group. You must separately verify the status of the abandoning action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AbandonInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AbandonInstancesInstanceGroupManagerRequest.
}
op, err := c.AbandonInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) AggregatedList
func (c *InstanceGroupManagersClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListInstanceGroupManagersRequest, opts ...gax.CallOption) *InstanceGroupManagersScopedListPairIterator
AggregatedList retrieves the list of managed instance groups and groups them by zone. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstanceGroupManagersRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupManagerAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstanceGroupManagersRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceGroupManagersClient) ApplyUpdatesToInstances
func (c *InstanceGroupManagersClient) ApplyUpdatesToInstances(ctx context.Context, req *computepb.ApplyUpdatesToInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
ApplyUpdatesToInstances applies changes to selected instances on the managed instance group. This method can be used to apply new overrides and/or new versions.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ApplyUpdatesToInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ApplyUpdatesToInstancesInstanceGroupManagerRequest.
}
op, err := c.ApplyUpdatesToInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) Close
func (c *InstanceGroupManagersClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InstanceGroupManagersClient) Connection (deprecated)
func (c *InstanceGroupManagersClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InstanceGroupManagersClient) CreateInstances
func (c *InstanceGroupManagersClient) CreateInstances(ctx context.Context, req *computepb.CreateInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
CreateInstances creates instances with per-instance configurations in this managed instance group. Instances are created using the current instance template. The create instances operation is marked DONE if the createInstances request is successful. The underlying actions take additional time. You must separately verify the status of the creating or actions with the listmanagedinstances method.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.CreateInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#CreateInstancesInstanceGroupManagerRequest.
}
op, err := c.CreateInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) Delete
func (c *InstanceGroupManagersClient) Delete(ctx context.Context, req *computepb.DeleteInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified managed instance group and all of the instances in that group. Note that the instance group must not belong to a backend service. Read Deleting an instance group for more information.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInstanceGroupManagerRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) DeleteInstances
func (c *InstanceGroupManagersClient) DeleteInstances(ctx context.Context, req *computepb.DeleteInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
DeleteInstances flags the specified instances in the managed instance group for immediate deletion. The instances are also removed from any target pools of which they were a member. This method reduces the targetSize of the managed instance group by the number of instances that you delete. This operation is marked as DONE when the action is scheduled even if the instances are still being deleted. You must separately verify the status of the deleting action with the listmanagedinstances method. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInstancesInstanceGroupManagerRequest.
}
op, err := c.DeleteInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) DeletePerInstanceConfigs
func (c *InstanceGroupManagersClient) DeletePerInstanceConfigs(ctx context.Context, req *computepb.DeletePerInstanceConfigsInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
DeletePerInstanceConfigs deletes selected per-instance configurations for the managed instance group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeletePerInstanceConfigsInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeletePerInstanceConfigsInstanceGroupManagerRequest.
}
op, err := c.DeletePerInstanceConfigs(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) Get
func (c *InstanceGroupManagersClient) Get(ctx context.Context, req *computepb.GetInstanceGroupManagerRequest, opts ...gax.CallOption) (*computepb.InstanceGroupManager, error)
Get returns all of the details about the specified managed instance group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInstanceGroupManagerRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstanceGroupManagersClient) Insert
func (c *InstanceGroupManagersClient) Insert(ctx context.Context, req *computepb.InsertInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a managed instance group using the information that you specify in the request. After the group is created, instances in the group are created using the specified instance template. This operation is marked as DONE when the group is created even if the instances in the group have not yet been created. You must separately verify the status of the individual instances with the listmanagedinstances method. A managed instance group can have up to 1000 VM instances per group. Please contact Cloud Support if you need an increase in this limit.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertInstanceGroupManagerRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) List
func (c *InstanceGroupManagersClient) List(ctx context.Context, req *computepb.ListInstanceGroupManagersRequest, opts ...gax.CallOption) *InstanceGroupManagerIterator
List retrieves a list of managed instance groups that are contained within the specified project and zone.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstanceGroupManagersRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupManagerList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstanceGroupManagersRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceGroupManagersClient) ListErrors
func (c *InstanceGroupManagersClient) ListErrors(ctx context.Context, req *computepb.ListErrorsInstanceGroupManagersRequest, opts ...gax.CallOption) *InstanceManagedByIgmErrorIterator
ListErrors lists all errors thrown by actions on instances for a given managed instance group. The filter and orderBy query parameters are not supported.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListErrorsInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListErrorsInstanceGroupManagersRequest.
}
it := c.ListErrors(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupManagersListErrorsResponse)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListErrorsInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListErrorsInstanceGroupManagersRequest.
}
for resp, err := range c.ListErrors(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceGroupManagersClient) ListManagedInstances
func (c *InstanceGroupManagersClient) ListManagedInstances(ctx context.Context, req *computepb.ListManagedInstancesInstanceGroupManagersRequest, opts ...gax.CallOption) *ManagedInstanceIterator
ListManagedInstances lists all of the instances in the managed instance group. Each instance in the list has a currentAction, which indicates the action that the managed instance group is performing on the instance. For example, if the group is still creating an instance, the currentAction is CREATING. If a previous action failed, the list displays the errors for that failed action. The orderBy query parameter is not supported. The pageToken query parameter is supported only if the group’s listManagedInstancesResults field is set to PAGINATED.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListManagedInstancesInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListManagedInstancesInstanceGroupManagersRequest.
}
it := c.ListManagedInstances(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupManagersListManagedInstancesResponse)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListManagedInstancesInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListManagedInstancesInstanceGroupManagersRequest.
}
for resp, err := range c.ListManagedInstances(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceGroupManagersClient) ListPerInstanceConfigs
func (c *InstanceGroupManagersClient) ListPerInstanceConfigs(ctx context.Context, req *computepb.ListPerInstanceConfigsInstanceGroupManagersRequest, opts ...gax.CallOption) *PerInstanceConfigIterator
ListPerInstanceConfigs lists all of the per-instance configurations defined for the managed instance group. The orderBy query parameter is not supported.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListPerInstanceConfigsInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListPerInstanceConfigsInstanceGroupManagersRequest.
}
it := c.ListPerInstanceConfigs(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupManagersListPerInstanceConfigsResp)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListPerInstanceConfigsInstanceGroupManagersRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListPerInstanceConfigsInstanceGroupManagersRequest.
}
for resp, err := range c.ListPerInstanceConfigs(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceGroupManagersClient) Patch
func (c *InstanceGroupManagersClient) Patch(ctx context.Context, req *computepb.PatchInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates a managed instance group using the information that you specify in the request. This operation is marked as DONE when the group is patched even if the instances in the group are still in the process of being patched. You must separately verify the status of the individual instances with the listManagedInstances method. This method supports PATCH semantics and uses the JSON merge patch format and processing rules. If you update your group to specify a new template or instance configuration, it’s possible that your intended specification for each VM in the group is different from the current state of that VM. To learn how to apply an updated configuration to the VMs in a MIG, see Updating instances in a MIG.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchInstanceGroupManagerRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) PatchPerInstanceConfigs
func (c *InstanceGroupManagersClient) PatchPerInstanceConfigs(ctx context.Context, req *computepb.PatchPerInstanceConfigsInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
PatchPerInstanceConfigs inserts or patches per-instance configurations for the managed instance group. perInstanceConfig.name (at http://perInstanceConfig.name) serves as a key used to distinguish whether to perform insert or patch.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchPerInstanceConfigsInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchPerInstanceConfigsInstanceGroupManagerRequest.
}
op, err := c.PatchPerInstanceConfigs(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) RecreateInstances
func (c *InstanceGroupManagersClient) RecreateInstances(ctx context.Context, req *computepb.RecreateInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
RecreateInstances flags the specified VM instances in the managed instance group to be immediately recreated. Each instance is recreated using the group’s current configuration. This operation is marked as DONE when the flag is set even if the instances have not yet been recreated. You must separately verify the status of each instance by checking its currentAction field; for more information, see Checking the status of managed instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted. You can specify a maximum of 1000 instances with this method per request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.RecreateInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#RecreateInstancesInstanceGroupManagerRequest.
}
op, err := c.RecreateInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) Resize
func (c *InstanceGroupManagersClient) Resize(ctx context.Context, req *computepb.ResizeInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
Resize resizes the managed instance group. If you increase the size, the group creates new instances using the current instance template. If you decrease the size, the group deletes instances. The resize operation is marked DONE when the resize actions are scheduled even if the group has not yet added or deleted any instances. You must separately verify the status of the creating or deleting actions with the listmanagedinstances method. When resizing down, the instance group arbitrarily chooses the order in which VMs are deleted. The group takes into account some VM attributes when making the selection including: + The status of the VM instance. + The health of the VM instance. + The instance template version the VM is based on. + For regional managed instance groups, the location of the VM instance. This list is subject to change. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is removed or deleted.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ResizeInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ResizeInstanceGroupManagerRequest.
}
op, err := c.Resize(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) ResumeInstances
func (c *InstanceGroupManagersClient) ResumeInstances(ctx context.Context, req *computepb.ResumeInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
ResumeInstances flags the specified instances in the managed instance group to be resumed. This method increases the targetSize and decreases the targetSuspendedSize of the managed instance group by the number of instances that you resume. The resumeInstances operation is marked DONE if the resumeInstances request is successful. The underlying actions take additional time. You must separately verify the status of the RESUMING action with the listmanagedinstances method. In this request, you can only specify instances that are suspended. For example, if an instance was previously suspended using the suspendInstances method, it can be resumed using the resumeInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are resumed. You can specify a maximum of 1000 instances with this method per request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ResumeInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ResumeInstancesInstanceGroupManagerRequest.
}
op, err := c.ResumeInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) SetInstanceTemplate
func (c *InstanceGroupManagersClient) SetInstanceTemplate(ctx context.Context, req *computepb.SetInstanceTemplateInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
SetInstanceTemplate specifies the instance template to use when creating new instances in this group. The templates for existing instances in the group do not change unless you run recreateInstances, run applyUpdatesToInstances, or set the group’s updatePolicy.type to PROACTIVE.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetInstanceTemplateInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetInstanceTemplateInstanceGroupManagerRequest.
}
op, err := c.SetInstanceTemplate(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) SetTargetPools
func (c *InstanceGroupManagersClient) SetTargetPools(ctx context.Context, req *computepb.SetTargetPoolsInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
SetTargetPools modifies the target pools to which all instances in this managed instance group are assigned. The target pools automatically apply to all of the instances in the managed instance group. This operation is marked DONE when you make the request even if the instances have not yet been added to their target pools. The change might take some time to apply to all of the instances in the group depending on the size of the group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetTargetPoolsInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetTargetPoolsInstanceGroupManagerRequest.
}
op, err := c.SetTargetPools(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) StartInstances
func (c *InstanceGroupManagersClient) StartInstances(ctx context.Context, req *computepb.StartInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
StartInstances flags the specified instances in the managed instance group to be started. This method increases the targetSize and decreases the targetStoppedSize of the managed instance group by the number of instances that you start. The startInstances operation is marked DONE if the startInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STARTING action with the listmanagedinstances method. In this request, you can only specify instances that are stopped. For example, if an instance was previously stopped using the stopInstances method, it can be started using the startInstances method. If a health check is attached to the managed instance group, the specified instances will be verified as healthy after they are started. You can specify a maximum of 1000 instances with this method per request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.StartInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#StartInstancesInstanceGroupManagerRequest.
}
op, err := c.StartInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) StopInstances
func (c *InstanceGroupManagersClient) StopInstances(ctx context.Context, req *computepb.StopInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
StopInstances flags the specified instances in the managed instance group to be immediately stopped. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetStoppedSize of the managed instance group by the number of instances that you stop. The stopInstances operation is marked DONE if the stopInstances request is successful. The underlying actions take additional time. You must separately verify the status of the STOPPING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays stopping the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is stopped. Stopped instances can be started using the startInstances method. You can specify a maximum of 1000 instances with this method per request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.StopInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#StopInstancesInstanceGroupManagerRequest.
}
op, err := c.StopInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) SuspendInstances
func (c *InstanceGroupManagersClient) SuspendInstances(ctx context.Context, req *computepb.SuspendInstancesInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
SuspendInstances flags the specified instances in the managed instance group to be immediately suspended. You can only specify instances that are running in this request. This method reduces the targetSize and increases the targetSuspendedSize of the managed instance group by the number of instances that you suspend. The suspendInstances operation is marked DONE if the suspendInstances request is successful. The underlying actions take additional time. You must separately verify the status of the SUSPENDING action with the listmanagedinstances method. If the standbyPolicy.initialDelaySec field is set, the group delays suspension of the instances until initialDelaySec have passed from instance.creationTimestamp (that is, when the instance was created). This delay gives your application time to set itself up and initialize on the instance. If more than initialDelaySec seconds have passed since instance.creationTimestamp when this method is called, there will be zero delay. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration has elapsed before the VM instance is suspended. Suspended instances can be resumed using the resumeInstances method. You can specify a maximum of 1000 instances with this method per request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SuspendInstancesInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SuspendInstancesInstanceGroupManagerRequest.
}
op, err := c.SuspendInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupManagersClient) UpdatePerInstanceConfigs
func (c *InstanceGroupManagersClient) UpdatePerInstanceConfigs(ctx context.Context, req *computepb.UpdatePerInstanceConfigsInstanceGroupManagerRequest, opts ...gax.CallOption) (*Operation, error)
UpdatePerInstanceConfigs inserts or updates per-instance configurations for the managed instance group. perInstanceConfig.name (at http://perInstanceConfig.name) serves as a key used to distinguish whether to perform insert or patch.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupManagersRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdatePerInstanceConfigsInstanceGroupManagerRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdatePerInstanceConfigsInstanceGroupManagerRequest.
}
op, err := c.UpdatePerInstanceConfigs(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
InstanceGroupManagersScopedListPair
type InstanceGroupManagersScopedListPair struct {
Key string
Value *computepb.InstanceGroupManagersScopedList
}
InstanceGroupManagersScopedListPair is a holder type for string/*computepb.InstanceGroupManagersScopedList map entries
InstanceGroupManagersScopedListPairIterator
type InstanceGroupManagersScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []InstanceGroupManagersScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceGroupManagersScopedListPairIterator manages a stream of InstanceGroupManagersScopedListPair.
func (*InstanceGroupManagersScopedListPairIterator) All
func (it *InstanceGroupManagersScopedListPairIterator) All() iter.Seq2[InstanceGroupManagersScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceGroupManagersScopedListPairIterator) Next
func (it *InstanceGroupManagersScopedListPairIterator) Next() (InstanceGroupManagersScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceGroupManagersScopedListPairIterator) PageInfo
func (it *InstanceGroupManagersScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceGroupsCallOptions
type InstanceGroupsCallOptions struct {
AddInstances []gax.CallOption
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListInstances []gax.CallOption
RemoveInstances []gax.CallOption
SetNamedPorts []gax.CallOption
}
InstanceGroupsCallOptions contains the retry settings for each method of InstanceGroupsClient.
InstanceGroupsClient
type InstanceGroupsClient struct {
// The call options for this service.
CallOptions *InstanceGroupsCallOptions
// contains filtered or unexported fields
}
InstanceGroupsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InstanceGroups API.
func NewInstanceGroupsRESTClient
func NewInstanceGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceGroupsClient, error)
NewInstanceGroupsRESTClient creates a new instance groups rest client.
The InstanceGroups API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InstanceGroupsClient) AddInstances
func (c *InstanceGroupsClient) AddInstances(ctx context.Context, req *computepb.AddInstancesInstanceGroupRequest, opts ...gax.CallOption) (*Operation, error)
AddInstances adds a list of instances to the specified instance group. All of the instances in the instance group must be in the same network/subnetwork. Read Adding instances for more information.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddInstancesInstanceGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddInstancesInstanceGroupRequest.
}
op, err := c.AddInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupsClient) AggregatedList
func (c *InstanceGroupsClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListInstanceGroupsRequest, opts ...gax.CallOption) *InstanceGroupsScopedListPairIterator
AggregatedList retrieves the list of instance groups and sorts them by zone. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstanceGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstanceGroupsRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstanceGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstanceGroupsRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceGroupsClient) Close
func (c *InstanceGroupsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InstanceGroupsClient) Connection (deprecated)
func (c *InstanceGroupsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InstanceGroupsClient) Delete
func (c *InstanceGroupsClient) Delete(ctx context.Context, req *computepb.DeleteInstanceGroupRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified instance group. The instances in the group are not deleted. Note that instance group must not belong to a backend service. Read Deleting an instance group for more information.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInstanceGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInstanceGroupRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupsClient) Get
func (c *InstanceGroupsClient) Get(ctx context.Context, req *computepb.GetInstanceGroupRequest, opts ...gax.CallOption) (*computepb.InstanceGroup, error)
Get returns the specified zonal instance group. Get a list of available zonal instance groups by making a list() request. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInstanceGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInstanceGroupRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstanceGroupsClient) Insert
func (c *InstanceGroupsClient) Insert(ctx context.Context, req *computepb.InsertInstanceGroupRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an instance group in the specified project using the parameters that are included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertInstanceGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertInstanceGroupRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupsClient) List
func (c *InstanceGroupsClient) List(ctx context.Context, req *computepb.ListInstanceGroupsRequest, opts ...gax.CallOption) *InstanceGroupIterator
List retrieves the list of zonal instance group resources contained within the specified zone. For managed instance groups, use the instanceGroupManagers or regionInstanceGroupManagers methods instead.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstanceGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstanceGroupsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstanceGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstanceGroupsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceGroupsClient) ListInstances
func (c *InstanceGroupsClient) ListInstances(ctx context.Context, req *computepb.ListInstancesInstanceGroupsRequest, opts ...gax.CallOption) *InstanceWithNamedPortsIterator
ListInstances lists the instances in the specified instance group. The orderBy query parameter is not supported. The filter query parameter is supported, but only for expressions that use eq (equal) or ne (not equal) operators.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstancesInstanceGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstancesInstanceGroupsRequest.
}
it := c.ListInstances(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceGroupsListInstances)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstancesInstanceGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstancesInstanceGroupsRequest.
}
for resp, err := range c.ListInstances(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceGroupsClient) RemoveInstances
func (c *InstanceGroupsClient) RemoveInstances(ctx context.Context, req *computepb.RemoveInstancesInstanceGroupRequest, opts ...gax.CallOption) (*Operation, error)
RemoveInstances removes one or more instances from the specified instance group, but does not delete those instances. If the group is part of a backend service that has enabled connection draining, it can take up to 60 seconds after the connection draining duration before the VM instance is removed or deleted.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.RemoveInstancesInstanceGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#RemoveInstancesInstanceGroupRequest.
}
op, err := c.RemoveInstances(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceGroupsClient) SetNamedPorts
func (c *InstanceGroupsClient) SetNamedPorts(ctx context.Context, req *computepb.SetNamedPortsInstanceGroupRequest, opts ...gax.CallOption) (*Operation, error)
SetNamedPorts sets the named ports for the specified instance group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetNamedPortsInstanceGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetNamedPortsInstanceGroupRequest.
}
op, err := c.SetNamedPorts(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
InstanceGroupsScopedListPair
type InstanceGroupsScopedListPair struct {
Key string
Value *computepb.InstanceGroupsScopedList
}
InstanceGroupsScopedListPair is a holder type for string/*computepb.InstanceGroupsScopedList map entries
InstanceGroupsScopedListPairIterator
type InstanceGroupsScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []InstanceGroupsScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceGroupsScopedListPairIterator manages a stream of InstanceGroupsScopedListPair.
func (*InstanceGroupsScopedListPairIterator) All
func (it *InstanceGroupsScopedListPairIterator) All() iter.Seq2[InstanceGroupsScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceGroupsScopedListPairIterator) Next
func (it *InstanceGroupsScopedListPairIterator) Next() (InstanceGroupsScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceGroupsScopedListPairIterator) PageInfo
func (it *InstanceGroupsScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceIterator
type InstanceIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.Instance, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceIterator manages a stream of *computepb.Instance.
func (*InstanceIterator) All
func (it *InstanceIterator) All() iter.Seq2[*computepb.Instance, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceIterator) Next
func (it *InstanceIterator) Next() (*computepb.Instance, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceIterator) PageInfo
func (it *InstanceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceManagedByIgmErrorIterator
type InstanceManagedByIgmErrorIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InstanceManagedByIgmError, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceManagedByIgmErrorIterator manages a stream of *computepb.InstanceManagedByIgmError.
func (*InstanceManagedByIgmErrorIterator) All
func (it *InstanceManagedByIgmErrorIterator) All() iter.Seq2[*computepb.InstanceManagedByIgmError, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceManagedByIgmErrorIterator) Next
func (it *InstanceManagedByIgmErrorIterator) Next() (*computepb.InstanceManagedByIgmError, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceManagedByIgmErrorIterator) PageInfo
func (it *InstanceManagedByIgmErrorIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceSettingsCallOptions
type InstanceSettingsCallOptions struct {
Get []gax.CallOption
Patch []gax.CallOption
}
InstanceSettingsCallOptions contains the retry settings for each method of InstanceSettingsClient.
InstanceSettingsClient
type InstanceSettingsClient struct {
// The call options for this service.
CallOptions *InstanceSettingsCallOptions
// contains filtered or unexported fields
}
InstanceSettingsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InstanceSettings API.
func NewInstanceSettingsRESTClient
func NewInstanceSettingsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceSettingsClient, error)
NewInstanceSettingsRESTClient creates a new instance settings service rest client.
The InstanceSettings API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceSettingsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InstanceSettingsClient) Close
func (c *InstanceSettingsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InstanceSettingsClient) Connection (deprecated)
func (c *InstanceSettingsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InstanceSettingsClient) Get
func (c *InstanceSettingsClient) Get(ctx context.Context, req *computepb.GetInstanceSettingRequest, opts ...gax.CallOption) (*computepb.InstanceSettings, error)
Get get Instance settings.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceSettingsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInstanceSettingRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInstanceSettingRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstanceSettingsClient) Patch
func (c *InstanceSettingsClient) Patch(ctx context.Context, req *computepb.PatchInstanceSettingRequest, opts ...gax.CallOption) (*Operation, error)
Patch patch Instance settings
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceSettingsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchInstanceSettingRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchInstanceSettingRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
InstanceTemplateIterator
type InstanceTemplateIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InstanceTemplate, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceTemplateIterator manages a stream of *computepb.InstanceTemplate.
func (*InstanceTemplateIterator) All
func (it *InstanceTemplateIterator) All() iter.Seq2[*computepb.InstanceTemplate, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceTemplateIterator) Next
func (it *InstanceTemplateIterator) Next() (*computepb.InstanceTemplate, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceTemplateIterator) PageInfo
func (it *InstanceTemplateIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceTemplatesCallOptions
type InstanceTemplatesCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
InstanceTemplatesCallOptions contains the retry settings for each method of InstanceTemplatesClient.
InstanceTemplatesClient
type InstanceTemplatesClient struct {
// The call options for this service.
CallOptions *InstanceTemplatesCallOptions
// contains filtered or unexported fields
}
InstanceTemplatesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InstanceTemplates API.
func NewInstanceTemplatesRESTClient
func NewInstanceTemplatesRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstanceTemplatesClient, error)
NewInstanceTemplatesRESTClient creates a new instance templates rest client.
The InstanceTemplates API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InstanceTemplatesClient) AggregatedList
func (c *InstanceTemplatesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListInstanceTemplatesRequest, opts ...gax.CallOption) *InstanceTemplatesScopedListPairIterator
AggregatedList retrieves the list of all InstanceTemplates resources, regional and global, available to the specified project. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstanceTemplatesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstanceTemplatesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceTemplateAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstanceTemplatesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstanceTemplatesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceTemplatesClient) Close
func (c *InstanceTemplatesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InstanceTemplatesClient) Connection (deprecated)
func (c *InstanceTemplatesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InstanceTemplatesClient) Delete
func (c *InstanceTemplatesClient) Delete(ctx context.Context, req *computepb.DeleteInstanceTemplateRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified instance template. Deleting an instance template is permanent and cannot be undone. It is not possible to delete templates that are already in use by a managed instance group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInstanceTemplateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInstanceTemplateRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceTemplatesClient) Get
func (c *InstanceTemplatesClient) Get(ctx context.Context, req *computepb.GetInstanceTemplateRequest, opts ...gax.CallOption) (*computepb.InstanceTemplate, error)
Get returns the specified instance template.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInstanceTemplateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInstanceTemplateRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstanceTemplatesClient) GetIamPolicy
func (c *InstanceTemplatesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyInstanceTemplateRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyInstanceTemplateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyInstanceTemplateRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstanceTemplatesClient) Insert
func (c *InstanceTemplatesClient) Insert(ctx context.Context, req *computepb.InsertInstanceTemplateRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an instance template in the specified project using the data that is included in the request. If you are creating a new template to update an existing instance group, your new instance template must use the same network or, if applicable, the same subnetwork as the original template.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertInstanceTemplateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertInstanceTemplateRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstanceTemplatesClient) List
func (c *InstanceTemplatesClient) List(ctx context.Context, req *computepb.ListInstanceTemplatesRequest, opts ...gax.CallOption) *InstanceTemplateIterator
List retrieves a list of instance templates that are contained within the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstanceTemplatesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstanceTemplatesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceTemplateList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstanceTemplatesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstanceTemplatesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstanceTemplatesClient) SetIamPolicy
func (c *InstanceTemplatesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyInstanceTemplateRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyInstanceTemplateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyInstanceTemplateRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstanceTemplatesClient) TestIamPermissions
func (c *InstanceTemplatesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsInstanceTemplateRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstanceTemplatesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsInstanceTemplateRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsInstanceTemplateRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
InstanceTemplatesScopedListPair
type InstanceTemplatesScopedListPair struct {
Key string
Value *computepb.InstanceTemplatesScopedList
}
InstanceTemplatesScopedListPair is a holder type for string/*computepb.InstanceTemplatesScopedList map entries
InstanceTemplatesScopedListPairIterator
type InstanceTemplatesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []InstanceTemplatesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceTemplatesScopedListPairIterator manages a stream of InstanceTemplatesScopedListPair.
func (*InstanceTemplatesScopedListPairIterator) All
func (it *InstanceTemplatesScopedListPairIterator) All() iter.Seq2[InstanceTemplatesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceTemplatesScopedListPairIterator) Next
func (it *InstanceTemplatesScopedListPairIterator) Next() (InstanceTemplatesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceTemplatesScopedListPairIterator) PageInfo
func (it *InstanceTemplatesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstanceWithNamedPortsIterator
type InstanceWithNamedPortsIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InstanceWithNamedPorts, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstanceWithNamedPortsIterator manages a stream of *computepb.InstanceWithNamedPorts.
func (*InstanceWithNamedPortsIterator) All
func (it *InstanceWithNamedPortsIterator) All() iter.Seq2[*computepb.InstanceWithNamedPorts, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstanceWithNamedPortsIterator) Next
func (it *InstanceWithNamedPortsIterator) Next() (*computepb.InstanceWithNamedPorts, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstanceWithNamedPortsIterator) PageInfo
func (it *InstanceWithNamedPortsIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstancesCallOptions
type InstancesCallOptions struct {
AddAccessConfig []gax.CallOption
AddResourcePolicies []gax.CallOption
AggregatedList []gax.CallOption
AttachDisk []gax.CallOption
BulkInsert []gax.CallOption
Delete []gax.CallOption
DeleteAccessConfig []gax.CallOption
DetachDisk []gax.CallOption
Get []gax.CallOption
GetEffectiveFirewalls []gax.CallOption
GetGuestAttributes []gax.CallOption
GetIamPolicy []gax.CallOption
GetScreenshot []gax.CallOption
GetSerialPortOutput []gax.CallOption
GetShieldedInstanceIdentity []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListReferrers []gax.CallOption
PerformMaintenance []gax.CallOption
RemoveResourcePolicies []gax.CallOption
Reset []gax.CallOption
Resume []gax.CallOption
SendDiagnosticInterrupt []gax.CallOption
SetDeletionProtection []gax.CallOption
SetDiskAutoDelete []gax.CallOption
SetIamPolicy []gax.CallOption
SetLabels []gax.CallOption
SetMachineResources []gax.CallOption
SetMachineType []gax.CallOption
SetMetadata []gax.CallOption
SetMinCpuPlatform []gax.CallOption
SetName []gax.CallOption
SetScheduling []gax.CallOption
SetSecurityPolicy []gax.CallOption
SetServiceAccount []gax.CallOption
SetShieldedInstanceIntegrityPolicy []gax.CallOption
SetTags []gax.CallOption
SimulateMaintenanceEvent []gax.CallOption
Start []gax.CallOption
StartWithEncryptionKey []gax.CallOption
Stop []gax.CallOption
Suspend []gax.CallOption
TestIamPermissions []gax.CallOption
Update []gax.CallOption
UpdateAccessConfig []gax.CallOption
UpdateDisplayDevice []gax.CallOption
UpdateNetworkInterface []gax.CallOption
UpdateShieldedInstanceConfig []gax.CallOption
}
InstancesCallOptions contains the retry settings for each method of InstancesClient.
InstancesClient
type InstancesClient struct {
// The call options for this service.
CallOptions *InstancesCallOptions
// contains filtered or unexported fields
}
InstancesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Instances API.
func NewInstancesRESTClient
func NewInstancesRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstancesClient, error)
NewInstancesRESTClient creates a new instances rest client.
The Instances API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InstancesClient) AddAccessConfig
func (c *InstancesClient) AddAccessConfig(ctx context.Context, req *computepb.AddAccessConfigInstanceRequest, opts ...gax.CallOption) (*Operation, error)
AddAccessConfig adds an access config to an instance’s network interface.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddAccessConfigInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddAccessConfigInstanceRequest.
}
op, err := c.AddAccessConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) AddResourcePolicies
func (c *InstancesClient) AddResourcePolicies(ctx context.Context, req *computepb.AddResourcePoliciesInstanceRequest, opts ...gax.CallOption) (*Operation, error)
AddResourcePolicies adds existing resource policies to an instance. You can only add one policy right now which will be applied to this instance for scheduling live migrations.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddResourcePoliciesInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddResourcePoliciesInstanceRequest.
}
op, err := c.AddResourcePolicies(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) AggregatedList
func (c *InstancesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListInstancesRequest, opts ...gax.CallOption) *InstancesScopedListPairIterator
AggregatedList retrieves an aggregated list of all of the instances in your project across all regions and zones. The performance of this method degrades when a filter is specified on a project that has a very large number of instances. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstancesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstancesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstancesClient) AttachDisk
func (c *InstancesClient) AttachDisk(ctx context.Context, req *computepb.AttachDiskInstanceRequest, opts ...gax.CallOption) (*Operation, error)
AttachDisk attaches an existing Disk resource to an instance. You must first create the disk before you can attach it. It is not possible to create and attach a disk at the same time. For more information, read Adding a persistent disk to your instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AttachDiskInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AttachDiskInstanceRequest.
}
op, err := c.AttachDisk(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) BulkInsert
func (c *InstancesClient) BulkInsert(ctx context.Context, req *computepb.BulkInsertInstanceRequest, opts ...gax.CallOption) (*Operation, error)
BulkInsert creates multiple instances. Count specifies the number of instances to create. For more information, see About bulk creation of VMs.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.BulkInsertInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#BulkInsertInstanceRequest.
}
op, err := c.BulkInsert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) Close
func (c *InstancesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InstancesClient) Connection (deprecated)
func (c *InstancesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InstancesClient) Delete
func (c *InstancesClient) Delete(ctx context.Context, req *computepb.DeleteInstanceRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified Instance resource. For more information, see Deleting an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInstanceRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) DeleteAccessConfig
func (c *InstancesClient) DeleteAccessConfig(ctx context.Context, req *computepb.DeleteAccessConfigInstanceRequest, opts ...gax.CallOption) (*Operation, error)
DeleteAccessConfig deletes an access config from an instance’s network interface.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteAccessConfigInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteAccessConfigInstanceRequest.
}
op, err := c.DeleteAccessConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) DetachDisk
func (c *InstancesClient) DetachDisk(ctx context.Context, req *computepb.DetachDiskInstanceRequest, opts ...gax.CallOption) (*Operation, error)
DetachDisk detaches a disk from an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DetachDiskInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DetachDiskInstanceRequest.
}
op, err := c.DetachDisk(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) Get
func (c *InstancesClient) Get(ctx context.Context, req *computepb.GetInstanceRequest, opts ...gax.CallOption) (*computepb.Instance, error)
Get returns the specified Instance resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInstanceRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) GetEffectiveFirewalls
func (c *InstancesClient) GetEffectiveFirewalls(ctx context.Context, req *computepb.GetEffectiveFirewallsInstanceRequest, opts ...gax.CallOption) (*computepb.InstancesGetEffectiveFirewallsResponse, error)
GetEffectiveFirewalls returns effective firewalls applied to an interface of the instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetEffectiveFirewallsInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetEffectiveFirewallsInstanceRequest.
}
resp, err := c.GetEffectiveFirewalls(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) GetGuestAttributes
func (c *InstancesClient) GetGuestAttributes(ctx context.Context, req *computepb.GetGuestAttributesInstanceRequest, opts ...gax.CallOption) (*computepb.GuestAttributes, error)
GetGuestAttributes returns the specified guest attributes entry.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetGuestAttributesInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetGuestAttributesInstanceRequest.
}
resp, err := c.GetGuestAttributes(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) GetIamPolicy
func (c *InstancesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyInstanceRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyInstanceRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) GetScreenshot
func (c *InstancesClient) GetScreenshot(ctx context.Context, req *computepb.GetScreenshotInstanceRequest, opts ...gax.CallOption) (*computepb.Screenshot, error)
GetScreenshot returns the screenshot from the specified instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetScreenshotInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetScreenshotInstanceRequest.
}
resp, err := c.GetScreenshot(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) GetSerialPortOutput
func (c *InstancesClient) GetSerialPortOutput(ctx context.Context, req *computepb.GetSerialPortOutputInstanceRequest, opts ...gax.CallOption) (*computepb.SerialPortOutput, error)
GetSerialPortOutput returns the last 1 MB of serial port output from the specified instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetSerialPortOutputInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetSerialPortOutputInstanceRequest.
}
resp, err := c.GetSerialPortOutput(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) GetShieldedInstanceIdentity
func (c *InstancesClient) GetShieldedInstanceIdentity(ctx context.Context, req *computepb.GetShieldedInstanceIdentityInstanceRequest, opts ...gax.CallOption) (*computepb.ShieldedInstanceIdentity, error)
GetShieldedInstanceIdentity returns the Shielded Instance Identity of an instance
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetShieldedInstanceIdentityInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetShieldedInstanceIdentityInstanceRequest.
}
resp, err := c.GetShieldedInstanceIdentity(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) Insert
func (c *InstancesClient) Insert(ctx context.Context, req *computepb.InsertInstanceRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an instance resource in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertInstanceRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) List
func (c *InstancesClient) List(ctx context.Context, req *computepb.ListInstancesRequest, opts ...gax.CallOption) *InstanceIterator
List retrieves the list of instances contained within the specified zone.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstancesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstancesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstancesClient) ListReferrers
func (c *InstancesClient) ListReferrers(ctx context.Context, req *computepb.ListReferrersInstancesRequest, opts ...gax.CallOption) *ReferenceIterator
ListReferrers retrieves a list of resources that refer to the VM instance specified in the request. For example, if the VM instance is part of a managed or unmanaged instance group, the referrers list includes the instance group. For more information, read Viewing referrers to VM instances.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListReferrersInstancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListReferrersInstancesRequest.
}
it := c.ListReferrers(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstanceListReferrers)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListReferrersInstancesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListReferrersInstancesRequest.
}
for resp, err := range c.ListReferrers(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstancesClient) PerformMaintenance
func (c *InstancesClient) PerformMaintenance(ctx context.Context, req *computepb.PerformMaintenanceInstanceRequest, opts ...gax.CallOption) (*Operation, error)
PerformMaintenance perform a manual maintenance on the instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PerformMaintenanceInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PerformMaintenanceInstanceRequest.
}
op, err := c.PerformMaintenance(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) RemoveResourcePolicies
func (c *InstancesClient) RemoveResourcePolicies(ctx context.Context, req *computepb.RemoveResourcePoliciesInstanceRequest, opts ...gax.CallOption) (*Operation, error)
RemoveResourcePolicies removes resource policies from an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.RemoveResourcePoliciesInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#RemoveResourcePoliciesInstanceRequest.
}
op, err := c.RemoveResourcePolicies(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) Reset
func (c *InstancesClient) Reset(ctx context.Context, req *computepb.ResetInstanceRequest, opts ...gax.CallOption) (*Operation, error)
Reset performs a reset on the instance. This is a hard reset. The VM does not do a graceful shutdown. For more information, see Resetting an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ResetInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ResetInstanceRequest.
}
op, err := c.Reset(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) Resume
func (c *InstancesClient) Resume(ctx context.Context, req *computepb.ResumeInstanceRequest, opts ...gax.CallOption) (*Operation, error)
Resume resumes an instance that was suspended using the instances().suspend method.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ResumeInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ResumeInstanceRequest.
}
op, err := c.Resume(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SendDiagnosticInterrupt
func (c *InstancesClient) SendDiagnosticInterrupt(ctx context.Context, req *computepb.SendDiagnosticInterruptInstanceRequest, opts ...gax.CallOption) (*computepb.SendDiagnosticInterruptInstanceResponse, error)
SendDiagnosticInterrupt sends diagnostic interrupt to the instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SendDiagnosticInterruptInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SendDiagnosticInterruptInstanceRequest.
}
resp, err := c.SendDiagnosticInterrupt(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) SetDeletionProtection
func (c *InstancesClient) SetDeletionProtection(ctx context.Context, req *computepb.SetDeletionProtectionInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetDeletionProtection sets deletion protection on the instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetDeletionProtectionInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetDeletionProtectionInstanceRequest.
}
op, err := c.SetDeletionProtection(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetDiskAutoDelete
func (c *InstancesClient) SetDiskAutoDelete(ctx context.Context, req *computepb.SetDiskAutoDeleteInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetDiskAutoDelete sets the auto-delete flag for a disk attached to an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetDiskAutoDeleteInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetDiskAutoDeleteInstanceRequest.
}
op, err := c.SetDiskAutoDelete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetIamPolicy
func (c *InstancesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyInstanceRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyInstanceRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) SetLabels
func (c *InstancesClient) SetLabels(ctx context.Context, req *computepb.SetLabelsInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets labels on an instance. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsInstanceRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetMachineResources
func (c *InstancesClient) SetMachineResources(ctx context.Context, req *computepb.SetMachineResourcesInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetMachineResources changes the number and/or type of accelerator for a stopped instance to the values specified in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetMachineResourcesInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetMachineResourcesInstanceRequest.
}
op, err := c.SetMachineResources(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetMachineType
func (c *InstancesClient) SetMachineType(ctx context.Context, req *computepb.SetMachineTypeInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetMachineType changes the machine type for a stopped instance to the machine type specified in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetMachineTypeInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetMachineTypeInstanceRequest.
}
op, err := c.SetMachineType(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetMetadata
func (c *InstancesClient) SetMetadata(ctx context.Context, req *computepb.SetMetadataInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetMetadata sets metadata for the specified instance to the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetMetadataInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetMetadataInstanceRequest.
}
op, err := c.SetMetadata(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetMinCpuPlatform
func (c *InstancesClient) SetMinCpuPlatform(ctx context.Context, req *computepb.SetMinCpuPlatformInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetMinCpuPlatform changes the minimum CPU platform that this instance should use. This method can only be called on a stopped instance. For more information, read Specifying a Minimum CPU Platform.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetMinCpuPlatformInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetMinCpuPlatformInstanceRequest.
}
op, err := c.SetMinCpuPlatform(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetName
func (c *InstancesClient) SetName(ctx context.Context, req *computepb.SetNameInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetName sets name of an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetNameInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetNameInstanceRequest.
}
op, err := c.SetName(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetScheduling
func (c *InstancesClient) SetScheduling(ctx context.Context, req *computepb.SetSchedulingInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetScheduling sets an instance’s scheduling options. You can only call this method on a stopped instance, that is, a VM instance that is in a TERMINATED state. See Instance Life Cycle for more information on the possible instance states. For more information about setting scheduling options for a VM, see Set VM host maintenance policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetSchedulingInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetSchedulingInstanceRequest.
}
op, err := c.SetScheduling(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetSecurityPolicy
func (c *InstancesClient) SetSecurityPolicy(ctx context.Context, req *computepb.SetSecurityPolicyInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetSecurityPolicy sets the Google Cloud Armor security policy for the specified instance. For more information, see Google Cloud Armor Overview
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetSecurityPolicyInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetSecurityPolicyInstanceRequest.
}
op, err := c.SetSecurityPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetServiceAccount
func (c *InstancesClient) SetServiceAccount(ctx context.Context, req *computepb.SetServiceAccountInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetServiceAccount sets the service account on the instance. For more information, read Changing the service account and access scopes for an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetServiceAccountInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetServiceAccountInstanceRequest.
}
op, err := c.SetServiceAccount(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetShieldedInstanceIntegrityPolicy
func (c *InstancesClient) SetShieldedInstanceIntegrityPolicy(ctx context.Context, req *computepb.SetShieldedInstanceIntegrityPolicyInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetShieldedInstanceIntegrityPolicy sets the Shielded Instance integrity policy for an instance. You can only use this method on a running instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetShieldedInstanceIntegrityPolicyInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetShieldedInstanceIntegrityPolicyInstanceRequest.
}
op, err := c.SetShieldedInstanceIntegrityPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SetTags
func (c *InstancesClient) SetTags(ctx context.Context, req *computepb.SetTagsInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SetTags sets network tags for the specified instance to the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetTagsInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetTagsInstanceRequest.
}
op, err := c.SetTags(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) SimulateMaintenanceEvent
func (c *InstancesClient) SimulateMaintenanceEvent(ctx context.Context, req *computepb.SimulateMaintenanceEventInstanceRequest, opts ...gax.CallOption) (*Operation, error)
SimulateMaintenanceEvent simulates a host maintenance event on a VM. For more information, see Simulate a host maintenance event.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SimulateMaintenanceEventInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SimulateMaintenanceEventInstanceRequest.
}
op, err := c.SimulateMaintenanceEvent(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) Start
func (c *InstancesClient) Start(ctx context.Context, req *computepb.StartInstanceRequest, opts ...gax.CallOption) (*Operation, error)
Start starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.StartInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#StartInstanceRequest.
}
op, err := c.Start(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) StartWithEncryptionKey
func (c *InstancesClient) StartWithEncryptionKey(ctx context.Context, req *computepb.StartWithEncryptionKeyInstanceRequest, opts ...gax.CallOption) (*Operation, error)
StartWithEncryptionKey starts an instance that was stopped using the instances().stop method. For more information, see Restart an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.StartWithEncryptionKeyInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#StartWithEncryptionKeyInstanceRequest.
}
op, err := c.StartWithEncryptionKey(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) Stop
func (c *InstancesClient) Stop(ctx context.Context, req *computepb.StopInstanceRequest, opts ...gax.CallOption) (*Operation, error)
Stop stops a running instance, shutting it down cleanly, and allows you to restart the instance at a later time. Stopped instances do not incur VM usage charges while they are stopped. However, resources that the VM is using, such as persistent disks and static IP addresses, will continue to be charged until they are deleted. For more information, see Stopping an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.StopInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#StopInstanceRequest.
}
op, err := c.Stop(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) Suspend
func (c *InstancesClient) Suspend(ctx context.Context, req *computepb.SuspendInstanceRequest, opts ...gax.CallOption) (*Operation, error)
Suspend this method suspends a running instance, saving its state to persistent storage, and allows you to resume the instance at a later time. Suspended instances have no compute costs (cores or RAM), and incur only storage charges for the saved VM memory and localSSD data. Any charged resources the virtual machine was using, such as persistent disks and static IP addresses, will continue to be charged while the instance is suspended. For more information, see Suspending and resuming an instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SuspendInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SuspendInstanceRequest.
}
op, err := c.Suspend(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) TestIamPermissions
func (c *InstancesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsInstanceRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsInstanceRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstancesClient) Update
func (c *InstancesClient) Update(ctx context.Context, req *computepb.UpdateInstanceRequest, opts ...gax.CallOption) (*Operation, error)
Update updates an instance only if the necessary resources are available. This method can update only a specific set of instance properties. See Updating a running instance for a list of updatable instance properties.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateInstanceRequest.
}
op, err := c.Update(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) UpdateAccessConfig
func (c *InstancesClient) UpdateAccessConfig(ctx context.Context, req *computepb.UpdateAccessConfigInstanceRequest, opts ...gax.CallOption) (*Operation, error)
UpdateAccessConfig updates the specified access config from an instance’s network interface with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateAccessConfigInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateAccessConfigInstanceRequest.
}
op, err := c.UpdateAccessConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) UpdateDisplayDevice
func (c *InstancesClient) UpdateDisplayDevice(ctx context.Context, req *computepb.UpdateDisplayDeviceInstanceRequest, opts ...gax.CallOption) (*Operation, error)
UpdateDisplayDevice updates the Display config for a VM instance. You can only use this method on a stopped VM instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateDisplayDeviceInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateDisplayDeviceInstanceRequest.
}
op, err := c.UpdateDisplayDevice(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) UpdateNetworkInterface
func (c *InstancesClient) UpdateNetworkInterface(ctx context.Context, req *computepb.UpdateNetworkInterfaceInstanceRequest, opts ...gax.CallOption) (*Operation, error)
UpdateNetworkInterface updates an instance’s network interface. This method can only update an interface’s alias IP range and attached network. See Modifying alias IP ranges for an existing instance for instructions on changing alias IP ranges. See Migrating a VM between networks for instructions on migrating an interface. This method follows PATCH semantics.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateNetworkInterfaceInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateNetworkInterfaceInstanceRequest.
}
op, err := c.UpdateNetworkInterface(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstancesClient) UpdateShieldedInstanceConfig
func (c *InstancesClient) UpdateShieldedInstanceConfig(ctx context.Context, req *computepb.UpdateShieldedInstanceConfigInstanceRequest, opts ...gax.CallOption) (*Operation, error)
UpdateShieldedInstanceConfig updates the Shielded Instance config for an instance. You can only use this method on a stopped instance. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstancesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.UpdateShieldedInstanceConfigInstanceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#UpdateShieldedInstanceConfigInstanceRequest.
}
op, err := c.UpdateShieldedInstanceConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
InstancesScopedListPair
type InstancesScopedListPair struct {
Key string
Value *computepb.InstancesScopedList
}
InstancesScopedListPair is a holder type for string/*computepb.InstancesScopedList map entries
InstancesScopedListPairIterator
type InstancesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []InstancesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstancesScopedListPairIterator manages a stream of InstancesScopedListPair.
func (*InstancesScopedListPairIterator) All
func (it *InstancesScopedListPairIterator) All() iter.Seq2[InstancesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstancesScopedListPairIterator) Next
func (it *InstancesScopedListPairIterator) Next() (InstancesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstancesScopedListPairIterator) PageInfo
func (it *InstancesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstantSnapshotIterator
type InstantSnapshotIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InstantSnapshot, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstantSnapshotIterator manages a stream of *computepb.InstantSnapshot.
func (*InstantSnapshotIterator) All
func (it *InstantSnapshotIterator) All() iter.Seq2[*computepb.InstantSnapshot, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstantSnapshotIterator) Next
func (it *InstantSnapshotIterator) Next() (*computepb.InstantSnapshot, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstantSnapshotIterator) PageInfo
func (it *InstantSnapshotIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InstantSnapshotsCallOptions
type InstantSnapshotsCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
SetIamPolicy []gax.CallOption
SetLabels []gax.CallOption
TestIamPermissions []gax.CallOption
}
InstantSnapshotsCallOptions contains the retry settings for each method of InstantSnapshotsClient.
InstantSnapshotsClient
type InstantSnapshotsClient struct {
// The call options for this service.
CallOptions *InstantSnapshotsCallOptions
// contains filtered or unexported fields
}
InstantSnapshotsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InstantSnapshots API.
func NewInstantSnapshotsRESTClient
func NewInstantSnapshotsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InstantSnapshotsClient, error)
NewInstantSnapshotsRESTClient creates a new instant snapshots rest client.
The InstantSnapshots API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InstantSnapshotsClient) AggregatedList
func (c *InstantSnapshotsClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListInstantSnapshotsRequest, opts ...gax.CallOption) *InstantSnapshotsScopedListPairIterator
AggregatedList retrieves an aggregated list of instantSnapshots. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstantSnapshotsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstantSnapshotsRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstantSnapshotAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInstantSnapshotsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInstantSnapshotsRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstantSnapshotsClient) Close
func (c *InstantSnapshotsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InstantSnapshotsClient) Connection (deprecated)
func (c *InstantSnapshotsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InstantSnapshotsClient) Delete
func (c *InstantSnapshotsClient) Delete(ctx context.Context, req *computepb.DeleteInstantSnapshotRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified InstantSnapshot resource. Keep in mind that deleting a single instantSnapshot might not necessarily delete all the data on that instantSnapshot. If any data on the instantSnapshot that is marked for deletion is needed for subsequent instantSnapshots, the data will be moved to the next corresponding instantSnapshot. For more information, see Deleting instantSnapshots.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInstantSnapshotRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInstantSnapshotRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstantSnapshotsClient) Get
func (c *InstantSnapshotsClient) Get(ctx context.Context, req *computepb.GetInstantSnapshotRequest, opts ...gax.CallOption) (*computepb.InstantSnapshot, error)
Get returns the specified InstantSnapshot resource in the specified zone.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInstantSnapshotRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInstantSnapshotRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstantSnapshotsClient) GetIamPolicy
func (c *InstantSnapshotsClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyInstantSnapshotRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyInstantSnapshotRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyInstantSnapshotRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstantSnapshotsClient) Insert
func (c *InstantSnapshotsClient) Insert(ctx context.Context, req *computepb.InsertInstantSnapshotRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an instant snapshot in the specified zone.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertInstantSnapshotRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertInstantSnapshotRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstantSnapshotsClient) List
func (c *InstantSnapshotsClient) List(ctx context.Context, req *computepb.ListInstantSnapshotsRequest, opts ...gax.CallOption) *InstantSnapshotIterator
List retrieves the list of InstantSnapshot resources contained within the specified zone.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstantSnapshotsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstantSnapshotsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InstantSnapshotList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInstantSnapshotsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInstantSnapshotsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InstantSnapshotsClient) SetIamPolicy
func (c *InstantSnapshotsClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyInstantSnapshotRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyInstantSnapshotRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyInstantSnapshotRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InstantSnapshotsClient) SetLabels
func (c *InstantSnapshotsClient) SetLabels(ctx context.Context, req *computepb.SetLabelsInstantSnapshotRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on a instantSnapshot in the given zone. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsInstantSnapshotRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsInstantSnapshotRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InstantSnapshotsClient) TestIamPermissions
func (c *InstantSnapshotsClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsInstantSnapshotRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInstantSnapshotsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsInstantSnapshotRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsInstantSnapshotRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
InstantSnapshotsScopedListPair
type InstantSnapshotsScopedListPair struct {
Key string
Value *computepb.InstantSnapshotsScopedList
}
InstantSnapshotsScopedListPair is a holder type for string/*computepb.InstantSnapshotsScopedList map entries
InstantSnapshotsScopedListPairIterator
type InstantSnapshotsScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []InstantSnapshotsScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
InstantSnapshotsScopedListPairIterator manages a stream of InstantSnapshotsScopedListPair.
func (*InstantSnapshotsScopedListPairIterator) All
func (it *InstantSnapshotsScopedListPairIterator) All() iter.Seq2[InstantSnapshotsScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InstantSnapshotsScopedListPairIterator) Next
func (it *InstantSnapshotsScopedListPairIterator) Next() (InstantSnapshotsScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InstantSnapshotsScopedListPairIterator) PageInfo
func (it *InstantSnapshotsScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InterconnectAttachmentIterator
type InterconnectAttachmentIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InterconnectAttachment, nextPageToken string, err error)
// contains filtered or unexported fields
}
InterconnectAttachmentIterator manages a stream of *computepb.InterconnectAttachment.
func (*InterconnectAttachmentIterator) All
func (it *InterconnectAttachmentIterator) All() iter.Seq2[*computepb.InterconnectAttachment, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InterconnectAttachmentIterator) Next
func (it *InterconnectAttachmentIterator) Next() (*computepb.InterconnectAttachment, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InterconnectAttachmentIterator) PageInfo
func (it *InterconnectAttachmentIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InterconnectAttachmentsCallOptions
type InterconnectAttachmentsCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetLabels []gax.CallOption
}
InterconnectAttachmentsCallOptions contains the retry settings for each method of InterconnectAttachmentsClient.
InterconnectAttachmentsClient
type InterconnectAttachmentsClient struct {
// The call options for this service.
CallOptions *InterconnectAttachmentsCallOptions
// contains filtered or unexported fields
}
InterconnectAttachmentsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InterconnectAttachments API.
func NewInterconnectAttachmentsRESTClient
func NewInterconnectAttachmentsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectAttachmentsClient, error)
NewInterconnectAttachmentsRESTClient creates a new interconnect attachments rest client.
The InterconnectAttachments API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InterconnectAttachmentsClient) AggregatedList
func (c *InterconnectAttachmentsClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListInterconnectAttachmentsRequest, opts ...gax.CallOption) *InterconnectAttachmentsScopedListPairIterator
AggregatedList retrieves an aggregated list of interconnect attachments. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInterconnectAttachmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInterconnectAttachmentsRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InterconnectAttachmentAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListInterconnectAttachmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListInterconnectAttachmentsRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InterconnectAttachmentsClient) Close
func (c *InterconnectAttachmentsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InterconnectAttachmentsClient) Connection (deprecated)
func (c *InterconnectAttachmentsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InterconnectAttachmentsClient) Delete
func (c *InterconnectAttachmentsClient) Delete(ctx context.Context, req *computepb.DeleteInterconnectAttachmentRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified interconnect attachment.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInterconnectAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInterconnectAttachmentRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InterconnectAttachmentsClient) Get
func (c *InterconnectAttachmentsClient) Get(ctx context.Context, req *computepb.GetInterconnectAttachmentRequest, opts ...gax.CallOption) (*computepb.InterconnectAttachment, error)
Get returns the specified interconnect attachment.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInterconnectAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInterconnectAttachmentRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InterconnectAttachmentsClient) Insert
func (c *InterconnectAttachmentsClient) Insert(ctx context.Context, req *computepb.InsertInterconnectAttachmentRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an InterconnectAttachment in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertInterconnectAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertInterconnectAttachmentRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InterconnectAttachmentsClient) List
func (c *InterconnectAttachmentsClient) List(ctx context.Context, req *computepb.ListInterconnectAttachmentsRequest, opts ...gax.CallOption) *InterconnectAttachmentIterator
List retrieves the list of interconnect attachments contained within the specified region.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInterconnectAttachmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInterconnectAttachmentsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InterconnectAttachmentList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInterconnectAttachmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInterconnectAttachmentsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InterconnectAttachmentsClient) Patch
func (c *InterconnectAttachmentsClient) Patch(ctx context.Context, req *computepb.PatchInterconnectAttachmentRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates the specified interconnect attachment with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchInterconnectAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchInterconnectAttachmentRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InterconnectAttachmentsClient) SetLabels
func (c *InterconnectAttachmentsClient) SetLabels(ctx context.Context, req *computepb.SetLabelsInterconnectAttachmentRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on an InterconnectAttachment. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsInterconnectAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsInterconnectAttachmentRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
InterconnectAttachmentsScopedListPair
type InterconnectAttachmentsScopedListPair struct {
Key string
Value *computepb.InterconnectAttachmentsScopedList
}
InterconnectAttachmentsScopedListPair is a holder type for string/*computepb.InterconnectAttachmentsScopedList map entries
InterconnectAttachmentsScopedListPairIterator
type InterconnectAttachmentsScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []InterconnectAttachmentsScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
InterconnectAttachmentsScopedListPairIterator manages a stream of InterconnectAttachmentsScopedListPair.
func (*InterconnectAttachmentsScopedListPairIterator) All
func (it *InterconnectAttachmentsScopedListPairIterator) All() iter.Seq2[InterconnectAttachmentsScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InterconnectAttachmentsScopedListPairIterator) Next
func (it *InterconnectAttachmentsScopedListPairIterator) Next() (InterconnectAttachmentsScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InterconnectAttachmentsScopedListPairIterator) PageInfo
func (it *InterconnectAttachmentsScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InterconnectIterator
type InterconnectIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.Interconnect, nextPageToken string, err error)
// contains filtered or unexported fields
}
InterconnectIterator manages a stream of *computepb.Interconnect.
func (*InterconnectIterator) All
func (it *InterconnectIterator) All() iter.Seq2[*computepb.Interconnect, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InterconnectIterator) Next
func (it *InterconnectIterator) Next() (*computepb.Interconnect, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InterconnectIterator) PageInfo
func (it *InterconnectIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InterconnectLocationIterator
type InterconnectLocationIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InterconnectLocation, nextPageToken string, err error)
// contains filtered or unexported fields
}
InterconnectLocationIterator manages a stream of *computepb.InterconnectLocation.
func (*InterconnectLocationIterator) All
func (it *InterconnectLocationIterator) All() iter.Seq2[*computepb.InterconnectLocation, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InterconnectLocationIterator) Next
func (it *InterconnectLocationIterator) Next() (*computepb.InterconnectLocation, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InterconnectLocationIterator) PageInfo
func (it *InterconnectLocationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InterconnectLocationsCallOptions
type InterconnectLocationsCallOptions struct {
Get []gax.CallOption
List []gax.CallOption
}
InterconnectLocationsCallOptions contains the retry settings for each method of InterconnectLocationsClient.
InterconnectLocationsClient
type InterconnectLocationsClient struct {
// The call options for this service.
CallOptions *InterconnectLocationsCallOptions
// contains filtered or unexported fields
}
InterconnectLocationsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InterconnectLocations API.
func NewInterconnectLocationsRESTClient
func NewInterconnectLocationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectLocationsClient, error)
NewInterconnectLocationsRESTClient creates a new interconnect locations rest client.
The InterconnectLocations API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectLocationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InterconnectLocationsClient) Close
func (c *InterconnectLocationsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InterconnectLocationsClient) Connection (deprecated)
func (c *InterconnectLocationsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InterconnectLocationsClient) Get
func (c *InterconnectLocationsClient) Get(ctx context.Context, req *computepb.GetInterconnectLocationRequest, opts ...gax.CallOption) (*computepb.InterconnectLocation, error)
Get returns the details for the specified interconnect location. Gets a list of available interconnect locations by making a list() request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectLocationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInterconnectLocationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInterconnectLocationRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InterconnectLocationsClient) List
func (c *InterconnectLocationsClient) List(ctx context.Context, req *computepb.ListInterconnectLocationsRequest, opts ...gax.CallOption) *InterconnectLocationIterator
List retrieves the list of interconnect locations available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectLocationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInterconnectLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInterconnectLocationsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InterconnectLocationList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectLocationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInterconnectLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInterconnectLocationsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
InterconnectRemoteLocationIterator
type InterconnectRemoteLocationIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.InterconnectRemoteLocation, nextPageToken string, err error)
// contains filtered or unexported fields
}
InterconnectRemoteLocationIterator manages a stream of *computepb.InterconnectRemoteLocation.
func (*InterconnectRemoteLocationIterator) All
func (it *InterconnectRemoteLocationIterator) All() iter.Seq2[*computepb.InterconnectRemoteLocation, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*InterconnectRemoteLocationIterator) Next
func (it *InterconnectRemoteLocationIterator) Next() (*computepb.InterconnectRemoteLocation, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*InterconnectRemoteLocationIterator) PageInfo
func (it *InterconnectRemoteLocationIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
InterconnectRemoteLocationsCallOptions
type InterconnectRemoteLocationsCallOptions struct {
Get []gax.CallOption
List []gax.CallOption
}
InterconnectRemoteLocationsCallOptions contains the retry settings for each method of InterconnectRemoteLocationsClient.
InterconnectRemoteLocationsClient
type InterconnectRemoteLocationsClient struct {
// The call options for this service.
CallOptions *InterconnectRemoteLocationsCallOptions
// contains filtered or unexported fields
}
InterconnectRemoteLocationsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The InterconnectRemoteLocations API.
func NewInterconnectRemoteLocationsRESTClient
func NewInterconnectRemoteLocationsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectRemoteLocationsClient, error)
NewInterconnectRemoteLocationsRESTClient creates a new interconnect remote locations rest client.
The InterconnectRemoteLocations API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectRemoteLocationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InterconnectRemoteLocationsClient) Close
func (c *InterconnectRemoteLocationsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InterconnectRemoteLocationsClient) Connection (deprecated)
func (c *InterconnectRemoteLocationsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InterconnectRemoteLocationsClient) Get
func (c *InterconnectRemoteLocationsClient) Get(ctx context.Context, req *computepb.GetInterconnectRemoteLocationRequest, opts ...gax.CallOption) (*computepb.InterconnectRemoteLocation, error)
Get returns the details for the specified interconnect remote location. Gets a list of available interconnect remote locations by making a list() request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectRemoteLocationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInterconnectRemoteLocationRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInterconnectRemoteLocationRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InterconnectRemoteLocationsClient) List
func (c *InterconnectRemoteLocationsClient) List(ctx context.Context, req *computepb.ListInterconnectRemoteLocationsRequest, opts ...gax.CallOption) *InterconnectRemoteLocationIterator
List retrieves the list of interconnect remote locations available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectRemoteLocationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInterconnectRemoteLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInterconnectRemoteLocationsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InterconnectRemoteLocationList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectRemoteLocationsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInterconnectRemoteLocationsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInterconnectRemoteLocationsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
InterconnectsCallOptions
type InterconnectsCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
GetDiagnostics []gax.CallOption
GetMacsecConfig []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetLabels []gax.CallOption
}
InterconnectsCallOptions contains the retry settings for each method of InterconnectsClient.
InterconnectsClient
type InterconnectsClient struct {
// The call options for this service.
CallOptions *InterconnectsCallOptions
// contains filtered or unexported fields
}
InterconnectsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Interconnects API.
func NewInterconnectsRESTClient
func NewInterconnectsRESTClient(ctx context.Context, opts ...option.ClientOption) (*InterconnectsClient, error)
NewInterconnectsRESTClient creates a new interconnects rest client.
The Interconnects API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*InterconnectsClient) Close
func (c *InterconnectsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*InterconnectsClient) Connection (deprecated)
func (c *InterconnectsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*InterconnectsClient) Delete
func (c *InterconnectsClient) Delete(ctx context.Context, req *computepb.DeleteInterconnectRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified Interconnect.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteInterconnectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteInterconnectRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InterconnectsClient) Get
func (c *InterconnectsClient) Get(ctx context.Context, req *computepb.GetInterconnectRequest, opts ...gax.CallOption) (*computepb.Interconnect, error)
Get returns the specified Interconnect. Get a list of available Interconnects by making a list() request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetInterconnectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetInterconnectRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InterconnectsClient) GetDiagnostics
func (c *InterconnectsClient) GetDiagnostics(ctx context.Context, req *computepb.GetDiagnosticsInterconnectRequest, opts ...gax.CallOption) (*computepb.InterconnectsGetDiagnosticsResponse, error)
GetDiagnostics returns the interconnectDiagnostics for the specified Interconnect. In the event of a global outage, do not use this API to make decisions about where to redirect your network traffic. Unlike a VLAN attachment, which is regional, a Cloud Interconnect connection is a global resource. A global outage can prevent this API from functioning properly.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetDiagnosticsInterconnectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetDiagnosticsInterconnectRequest.
}
resp, err := c.GetDiagnostics(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InterconnectsClient) GetMacsecConfig
func (c *InterconnectsClient) GetMacsecConfig(ctx context.Context, req *computepb.GetMacsecConfigInterconnectRequest, opts ...gax.CallOption) (*computepb.InterconnectsGetMacsecConfigResponse, error)
GetMacsecConfig returns the interconnectMacsecConfig for the specified Interconnect.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetMacsecConfigInterconnectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetMacsecConfigInterconnectRequest.
}
resp, err := c.GetMacsecConfig(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*InterconnectsClient) Insert
func (c *InterconnectsClient) Insert(ctx context.Context, req *computepb.InsertInterconnectRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates an Interconnect in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertInterconnectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertInterconnectRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InterconnectsClient) List
func (c *InterconnectsClient) List(ctx context.Context, req *computepb.ListInterconnectsRequest, opts ...gax.CallOption) *InterconnectIterator
List retrieves the list of Interconnects available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInterconnectsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInterconnectsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.InterconnectList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListInterconnectsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListInterconnectsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*InterconnectsClient) Patch
func (c *InterconnectsClient) Patch(ctx context.Context, req *computepb.PatchInterconnectRequest, opts ...gax.CallOption) (*Operation, error)
Patch updates the specified Interconnect with the data included in the request. This method supports PATCH semantics and uses the JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchInterconnectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchInterconnectRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*InterconnectsClient) SetLabels
func (c *InterconnectsClient) SetLabels(ctx context.Context, req *computepb.SetLabelsInterconnectRequest, opts ...gax.CallOption) (*Operation, error)
SetLabels sets the labels on an Interconnect. To learn more about labels, read the Labeling Resources documentation.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewInterconnectsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetLabelsInterconnectRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetLabelsInterconnectRequest.
}
op, err := c.SetLabels(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
LicenseCodesCallOptions
type LicenseCodesCallOptions struct {
Get []gax.CallOption
TestIamPermissions []gax.CallOption
}
LicenseCodesCallOptions contains the retry settings for each method of LicenseCodesClient.
LicenseCodesClient
type LicenseCodesClient struct {
// The call options for this service.
CallOptions *LicenseCodesCallOptions
// contains filtered or unexported fields
}
LicenseCodesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The LicenseCodes API.
func NewLicenseCodesRESTClient
func NewLicenseCodesRESTClient(ctx context.Context, opts ...option.ClientOption) (*LicenseCodesClient, error)
NewLicenseCodesRESTClient creates a new license codes rest client.
The LicenseCodes API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicenseCodesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*LicenseCodesClient) Close
func (c *LicenseCodesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*LicenseCodesClient) Connection (deprecated)
func (c *LicenseCodesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*LicenseCodesClient) Get
func (c *LicenseCodesClient) Get(ctx context.Context, req *computepb.GetLicenseCodeRequest, opts ...gax.CallOption) (*computepb.LicenseCode, error)
Get return a specified license code. License codes are mirrored across all projects that have permissions to read the License Code. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicenseCodesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetLicenseCodeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetLicenseCodeRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*LicenseCodesClient) TestIamPermissions
func (c *LicenseCodesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsLicenseCodeRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicenseCodesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsLicenseCodeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsLicenseCodeRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
LicenseIterator
type LicenseIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.License, nextPageToken string, err error)
// contains filtered or unexported fields
}
LicenseIterator manages a stream of *computepb.License.
func (*LicenseIterator) All
func (it *LicenseIterator) All() iter.Seq2[*computepb.License, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*LicenseIterator) Next
func (it *LicenseIterator) Next() (*computepb.License, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*LicenseIterator) PageInfo
func (it *LicenseIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
LicensesCallOptions
type LicensesCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
LicensesCallOptions contains the retry settings for each method of LicensesClient.
LicensesClient
type LicensesClient struct {
// The call options for this service.
CallOptions *LicensesCallOptions
// contains filtered or unexported fields
}
LicensesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The Licenses API.
func NewLicensesRESTClient
func NewLicensesRESTClient(ctx context.Context, opts ...option.ClientOption) (*LicensesClient, error)
NewLicensesRESTClient creates a new licenses rest client.
The Licenses API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*LicensesClient) Close
func (c *LicensesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*LicensesClient) Connection (deprecated)
func (c *LicensesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*LicensesClient) Delete
func (c *LicensesClient) Delete(ctx context.Context, req *computepb.DeleteLicenseRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified license. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteLicenseRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteLicenseRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*LicensesClient) Get
func (c *LicensesClient) Get(ctx context.Context, req *computepb.GetLicenseRequest, opts ...gax.CallOption) (*computepb.License, error)
Get returns the specified License resource. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetLicenseRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetLicenseRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*LicensesClient) GetIamPolicy
func (c *LicensesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyLicenseRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyLicenseRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyLicenseRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*LicensesClient) Insert
func (c *LicensesClient) Insert(ctx context.Context, req *computepb.InsertLicenseRequest, opts ...gax.CallOption) (*Operation, error)
Insert create a License resource in the specified project. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertLicenseRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertLicenseRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*LicensesClient) List
func (c *LicensesClient) List(ctx context.Context, req *computepb.ListLicensesRequest, opts ...gax.CallOption) *LicenseIterator
List retrieves the list of licenses available in the specified project. This method does not get any licenses that belong to other projects, including licenses attached to publicly-available images, like Debian 9. If you want to get a list of publicly-available licenses, use this method to make a request to the respective image project, such as debian-cloud or windows-cloud. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListLicensesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListLicensesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.LicensesListResponse)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListLicensesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListLicensesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*LicensesClient) SetIamPolicy
func (c *LicensesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyLicenseRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyLicenseRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyLicenseRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*LicensesClient) TestIamPermissions
func (c *LicensesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsLicenseRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource. Caution This resource is intended for use only by third-party partners who are creating Cloud Marketplace images.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewLicensesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsLicenseRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsLicenseRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
MachineImageIterator
type MachineImageIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.MachineImage, nextPageToken string, err error)
// contains filtered or unexported fields
}
MachineImageIterator manages a stream of *computepb.MachineImage.
func (*MachineImageIterator) All
func (it *MachineImageIterator) All() iter.Seq2[*computepb.MachineImage, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*MachineImageIterator) Next
func (it *MachineImageIterator) Next() (*computepb.MachineImage, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*MachineImageIterator) PageInfo
func (it *MachineImageIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
MachineImagesCallOptions
type MachineImagesCallOptions struct {
Delete []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
MachineImagesCallOptions contains the retry settings for each method of MachineImagesClient.
MachineImagesClient
type MachineImagesClient struct {
// The call options for this service.
CallOptions *MachineImagesCallOptions
// contains filtered or unexported fields
}
MachineImagesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The MachineImages API.
func NewMachineImagesRESTClient
func NewMachineImagesRESTClient(ctx context.Context, opts ...option.ClientOption) (*MachineImagesClient, error)
NewMachineImagesRESTClient creates a new machine images rest client.
The MachineImages API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*MachineImagesClient) Close
func (c *MachineImagesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*MachineImagesClient) Connection (deprecated)
func (c *MachineImagesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*MachineImagesClient) Delete
func (c *MachineImagesClient) Delete(ctx context.Context, req *computepb.DeleteMachineImageRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified machine image. Deleting a machine image is permanent and cannot be undone.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteMachineImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteMachineImageRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*MachineImagesClient) Get
func (c *MachineImagesClient) Get(ctx context.Context, req *computepb.GetMachineImageRequest, opts ...gax.CallOption) (*computepb.MachineImage, error)
Get returns the specified machine image.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetMachineImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetMachineImageRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MachineImagesClient) GetIamPolicy
func (c *MachineImagesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyMachineImageRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyMachineImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyMachineImageRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MachineImagesClient) Insert
func (c *MachineImagesClient) Insert(ctx context.Context, req *computepb.InsertMachineImageRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a machine image in the specified project using the data that is included in the request. If you are creating a new machine image to update an existing instance, your new machine image should use the same network or, if applicable, the same subnetwork as the original instance.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertMachineImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertMachineImageRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*MachineImagesClient) List
func (c *MachineImagesClient) List(ctx context.Context, req *computepb.ListMachineImagesRequest, opts ...gax.CallOption) *MachineImageIterator
List retrieves a list of machine images that are contained within the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListMachineImagesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListMachineImagesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.MachineImageList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListMachineImagesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListMachineImagesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*MachineImagesClient) SetIamPolicy
func (c *MachineImagesClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyMachineImageRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyMachineImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyMachineImageRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MachineImagesClient) TestIamPermissions
func (c *MachineImagesClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsMachineImageRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineImagesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsMachineImageRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsMachineImageRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
MachineTypeIterator
type MachineTypeIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.MachineType, nextPageToken string, err error)
// contains filtered or unexported fields
}
MachineTypeIterator manages a stream of *computepb.MachineType.
func (*MachineTypeIterator) All
func (it *MachineTypeIterator) All() iter.Seq2[*computepb.MachineType, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*MachineTypeIterator) Next
func (it *MachineTypeIterator) Next() (*computepb.MachineType, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*MachineTypeIterator) PageInfo
func (it *MachineTypeIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
MachineTypesCallOptions
type MachineTypesCallOptions struct {
AggregatedList []gax.CallOption
Get []gax.CallOption
List []gax.CallOption
}
MachineTypesCallOptions contains the retry settings for each method of MachineTypesClient.
MachineTypesClient
type MachineTypesClient struct {
// The call options for this service.
CallOptions *MachineTypesCallOptions
// contains filtered or unexported fields
}
MachineTypesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The MachineTypes API.
func NewMachineTypesRESTClient
func NewMachineTypesRESTClient(ctx context.Context, opts ...option.ClientOption) (*MachineTypesClient, error)
NewMachineTypesRESTClient creates a new machine types rest client.
The MachineTypes API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*MachineTypesClient) AggregatedList
func (c *MachineTypesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListMachineTypesRequest, opts ...gax.CallOption) *MachineTypesScopedListPairIterator
AggregatedList retrieves an aggregated list of machine types. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListMachineTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListMachineTypesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.MachineTypeAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListMachineTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListMachineTypesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*MachineTypesClient) Close
func (c *MachineTypesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*MachineTypesClient) Connection (deprecated)
func (c *MachineTypesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*MachineTypesClient) Get
func (c *MachineTypesClient) Get(ctx context.Context, req *computepb.GetMachineTypeRequest, opts ...gax.CallOption) (*computepb.MachineType, error)
Get returns the specified machine type.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetMachineTypeRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetMachineTypeRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*MachineTypesClient) List
func (c *MachineTypesClient) List(ctx context.Context, req *computepb.ListMachineTypesRequest, opts ...gax.CallOption) *MachineTypeIterator
List retrieves a list of machine types available to the specified project.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListMachineTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListMachineTypesRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.MachineTypeList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewMachineTypesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListMachineTypesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListMachineTypesRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
MachineTypesScopedListPair
type MachineTypesScopedListPair struct {
Key string
Value *computepb.MachineTypesScopedList
}
MachineTypesScopedListPair is a holder type for string/*computepb.MachineTypesScopedList map entries
MachineTypesScopedListPairIterator
type MachineTypesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []MachineTypesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
MachineTypesScopedListPairIterator manages a stream of MachineTypesScopedListPair.
func (*MachineTypesScopedListPairIterator) All
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*MachineTypesScopedListPairIterator) Next
func (it *MachineTypesScopedListPairIterator) Next() (MachineTypesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*MachineTypesScopedListPairIterator) PageInfo
func (it *MachineTypesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
ManagedInstanceIterator
type ManagedInstanceIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.ManagedInstance, nextPageToken string, err error)
// contains filtered or unexported fields
}
ManagedInstanceIterator manages a stream of *computepb.ManagedInstance.
func (*ManagedInstanceIterator) All
func (it *ManagedInstanceIterator) All() iter.Seq2[*computepb.ManagedInstance, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*ManagedInstanceIterator) Next
func (it *ManagedInstanceIterator) Next() (*computepb.ManagedInstance, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*ManagedInstanceIterator) PageInfo
func (it *ManagedInstanceIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
NetworkAttachmentIterator
type NetworkAttachmentIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.NetworkAttachment, nextPageToken string, err error)
// contains filtered or unexported fields
}
NetworkAttachmentIterator manages a stream of *computepb.NetworkAttachment.
func (*NetworkAttachmentIterator) All
func (it *NetworkAttachmentIterator) All() iter.Seq2[*computepb.NetworkAttachment, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*NetworkAttachmentIterator) Next
func (it *NetworkAttachmentIterator) Next() (*computepb.NetworkAttachment, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*NetworkAttachmentIterator) PageInfo
func (it *NetworkAttachmentIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
NetworkAttachmentsCallOptions
type NetworkAttachmentsCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetIamPolicy []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
NetworkAttachmentsCallOptions contains the retry settings for each method of NetworkAttachmentsClient.
NetworkAttachmentsClient
type NetworkAttachmentsClient struct {
// The call options for this service.
CallOptions *NetworkAttachmentsCallOptions
// contains filtered or unexported fields
}
NetworkAttachmentsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The NetworkAttachments API.
func NewNetworkAttachmentsRESTClient
func NewNetworkAttachmentsRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkAttachmentsClient, error)
NewNetworkAttachmentsRESTClient creates a new network attachments rest client.
The NetworkAttachments API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*NetworkAttachmentsClient) AggregatedList
func (c *NetworkAttachmentsClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListNetworkAttachmentsRequest, opts ...gax.CallOption) *NetworkAttachmentsScopedListPairIterator
AggregatedList retrieves the list of all NetworkAttachment resources, regional and global, available to the specified project. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListNetworkAttachmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListNetworkAttachmentsRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkAttachmentAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListNetworkAttachmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListNetworkAttachmentsRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*NetworkAttachmentsClient) Close
func (c *NetworkAttachmentsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*NetworkAttachmentsClient) Connection (deprecated)
func (c *NetworkAttachmentsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*NetworkAttachmentsClient) Delete
func (c *NetworkAttachmentsClient) Delete(ctx context.Context, req *computepb.DeleteNetworkAttachmentRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified NetworkAttachment in the given scope
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteNetworkAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteNetworkAttachmentRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkAttachmentsClient) Get
func (c *NetworkAttachmentsClient) Get(ctx context.Context, req *computepb.GetNetworkAttachmentRequest, opts ...gax.CallOption) (*computepb.NetworkAttachment, error)
Get returns the specified NetworkAttachment resource in the given scope.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetNetworkAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetNetworkAttachmentRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkAttachmentsClient) GetIamPolicy
func (c *NetworkAttachmentsClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyNetworkAttachmentRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyNetworkAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyNetworkAttachmentRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkAttachmentsClient) Insert
func (c *NetworkAttachmentsClient) Insert(ctx context.Context, req *computepb.InsertNetworkAttachmentRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a NetworkAttachment in the specified project in the given scope using the parameters that are included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertNetworkAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertNetworkAttachmentRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkAttachmentsClient) List
func (c *NetworkAttachmentsClient) List(ctx context.Context, req *computepb.ListNetworkAttachmentsRequest, opts ...gax.CallOption) *NetworkAttachmentIterator
List lists the NetworkAttachments for a project in the given scope.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListNetworkAttachmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListNetworkAttachmentsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkAttachmentList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListNetworkAttachmentsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListNetworkAttachmentsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*NetworkAttachmentsClient) Patch
func (c *NetworkAttachmentsClient) Patch(ctx context.Context, req *computepb.PatchNetworkAttachmentRequest, opts ...gax.CallOption) (*Operation, error)
Patch patches the specified NetworkAttachment resource with the data included in the request. This method supports PATCH semantics and uses JSON merge patch format and processing rules.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchNetworkAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchNetworkAttachmentRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkAttachmentsClient) SetIamPolicy
func (c *NetworkAttachmentsClient) SetIamPolicy(ctx context.Context, req *computepb.SetIamPolicyNetworkAttachmentRequest, opts ...gax.CallOption) (*computepb.Policy, error)
SetIamPolicy sets the access control policy on the specified resource. Replaces any existing policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.SetIamPolicyNetworkAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#SetIamPolicyNetworkAttachmentRequest.
}
resp, err := c.SetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkAttachmentsClient) TestIamPermissions
func (c *NetworkAttachmentsClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsNetworkAttachmentRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkAttachmentsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsNetworkAttachmentRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsNetworkAttachmentRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
NetworkAttachmentsScopedListPair
type NetworkAttachmentsScopedListPair struct {
Key string
Value *computepb.NetworkAttachmentsScopedList
}
NetworkAttachmentsScopedListPair is a holder type for string/*computepb.NetworkAttachmentsScopedList map entries
NetworkAttachmentsScopedListPairIterator
type NetworkAttachmentsScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []NetworkAttachmentsScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
NetworkAttachmentsScopedListPairIterator manages a stream of NetworkAttachmentsScopedListPair.
func (*NetworkAttachmentsScopedListPairIterator) All
func (it *NetworkAttachmentsScopedListPairIterator) All() iter.Seq2[NetworkAttachmentsScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*NetworkAttachmentsScopedListPairIterator) Next
func (it *NetworkAttachmentsScopedListPairIterator) Next() (NetworkAttachmentsScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*NetworkAttachmentsScopedListPairIterator) PageInfo
func (it *NetworkAttachmentsScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
NetworkEdgeSecurityServicesCallOptions
type NetworkEdgeSecurityServicesCallOptions struct {
AggregatedList []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
Patch []gax.CallOption
}
NetworkEdgeSecurityServicesCallOptions contains the retry settings for each method of NetworkEdgeSecurityServicesClient.
NetworkEdgeSecurityServicesClient
type NetworkEdgeSecurityServicesClient struct {
// The call options for this service.
CallOptions *NetworkEdgeSecurityServicesCallOptions
// contains filtered or unexported fields
}
NetworkEdgeSecurityServicesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The NetworkEdgeSecurityServices API.
func NewNetworkEdgeSecurityServicesRESTClient
func NewNetworkEdgeSecurityServicesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkEdgeSecurityServicesClient, error)
NewNetworkEdgeSecurityServicesRESTClient creates a new network edge security services rest client.
The NetworkEdgeSecurityServices API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*NetworkEdgeSecurityServicesClient) AggregatedList
func (c *NetworkEdgeSecurityServicesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListNetworkEdgeSecurityServicesRequest, opts ...gax.CallOption) *NetworkEdgeSecurityServicesScopedListPairIterator
AggregatedList retrieves the list of all NetworkEdgeSecurityService resources available to the specified project. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListNetworkEdgeSecurityServicesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListNetworkEdgeSecurityServicesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkEdgeSecurityServiceAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListNetworkEdgeSecurityServicesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListNetworkEdgeSecurityServicesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*NetworkEdgeSecurityServicesClient) Close
func (c *NetworkEdgeSecurityServicesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*NetworkEdgeSecurityServicesClient) Connection (deprecated)
func (c *NetworkEdgeSecurityServicesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*NetworkEdgeSecurityServicesClient) Delete
func (c *NetworkEdgeSecurityServicesClient) Delete(ctx context.Context, req *computepb.DeleteNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified service.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteNetworkEdgeSecurityServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteNetworkEdgeSecurityServiceRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkEdgeSecurityServicesClient) Get
func (c *NetworkEdgeSecurityServicesClient) Get(ctx context.Context, req *computepb.GetNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*computepb.NetworkEdgeSecurityService, error)
Get gets a specified NetworkEdgeSecurityService.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetNetworkEdgeSecurityServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetNetworkEdgeSecurityServiceRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkEdgeSecurityServicesClient) Insert
func (c *NetworkEdgeSecurityServicesClient) Insert(ctx context.Context, req *computepb.InsertNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a new service in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertNetworkEdgeSecurityServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertNetworkEdgeSecurityServiceRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkEdgeSecurityServicesClient) Patch
func (c *NetworkEdgeSecurityServicesClient) Patch(ctx context.Context, req *computepb.PatchNetworkEdgeSecurityServiceRequest, opts ...gax.CallOption) (*Operation, error)
Patch patches the specified policy with the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEdgeSecurityServicesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.PatchNetworkEdgeSecurityServiceRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#PatchNetworkEdgeSecurityServiceRequest.
}
op, err := c.Patch(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
NetworkEdgeSecurityServicesScopedListPair
type NetworkEdgeSecurityServicesScopedListPair struct {
Key string
Value *computepb.NetworkEdgeSecurityServicesScopedList
}
NetworkEdgeSecurityServicesScopedListPair is a holder type for string/*computepb.NetworkEdgeSecurityServicesScopedList map entries
NetworkEdgeSecurityServicesScopedListPairIterator
type NetworkEdgeSecurityServicesScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []NetworkEdgeSecurityServicesScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
NetworkEdgeSecurityServicesScopedListPairIterator manages a stream of NetworkEdgeSecurityServicesScopedListPair.
func (*NetworkEdgeSecurityServicesScopedListPairIterator) All
func (it *NetworkEdgeSecurityServicesScopedListPairIterator) All() iter.Seq2[NetworkEdgeSecurityServicesScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*NetworkEdgeSecurityServicesScopedListPairIterator) Next
func (it *NetworkEdgeSecurityServicesScopedListPairIterator) Next() (NetworkEdgeSecurityServicesScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*NetworkEdgeSecurityServicesScopedListPairIterator) PageInfo
func (it *NetworkEdgeSecurityServicesScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
NetworkEndpointGroupIterator
type NetworkEndpointGroupIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.NetworkEndpointGroup, nextPageToken string, err error)
// contains filtered or unexported fields
}
NetworkEndpointGroupIterator manages a stream of *computepb.NetworkEndpointGroup.
func (*NetworkEndpointGroupIterator) All
func (it *NetworkEndpointGroupIterator) All() iter.Seq2[*computepb.NetworkEndpointGroup, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*NetworkEndpointGroupIterator) Next
func (it *NetworkEndpointGroupIterator) Next() (*computepb.NetworkEndpointGroup, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*NetworkEndpointGroupIterator) PageInfo
func (it *NetworkEndpointGroupIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
NetworkEndpointGroupsCallOptions
type NetworkEndpointGroupsCallOptions struct {
AggregatedList []gax.CallOption
AttachNetworkEndpoints []gax.CallOption
Delete []gax.CallOption
DetachNetworkEndpoints []gax.CallOption
Get []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
ListNetworkEndpoints []gax.CallOption
TestIamPermissions []gax.CallOption
}
NetworkEndpointGroupsCallOptions contains the retry settings for each method of NetworkEndpointGroupsClient.
NetworkEndpointGroupsClient
type NetworkEndpointGroupsClient struct {
// The call options for this service.
CallOptions *NetworkEndpointGroupsCallOptions
// contains filtered or unexported fields
}
NetworkEndpointGroupsClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The NetworkEndpointGroups API.
func NewNetworkEndpointGroupsRESTClient
func NewNetworkEndpointGroupsRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkEndpointGroupsClient, error)
NewNetworkEndpointGroupsRESTClient creates a new network endpoint groups rest client.
The NetworkEndpointGroups API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*NetworkEndpointGroupsClient) AggregatedList
func (c *NetworkEndpointGroupsClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListNetworkEndpointGroupsRequest, opts ...gax.CallOption) *NetworkEndpointGroupsScopedListPairIterator
AggregatedList retrieves the list of network endpoint groups and sorts them by zone. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListNetworkEndpointGroupsRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkEndpointGroupAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListNetworkEndpointGroupsRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*NetworkEndpointGroupsClient) AttachNetworkEndpoints
func (c *NetworkEndpointGroupsClient) AttachNetworkEndpoints(ctx context.Context, req *computepb.AttachNetworkEndpointsNetworkEndpointGroupRequest, opts ...gax.CallOption) (*Operation, error)
AttachNetworkEndpoints attach a list of network endpoints to the specified network endpoint group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AttachNetworkEndpointsNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AttachNetworkEndpointsNetworkEndpointGroupRequest.
}
op, err := c.AttachNetworkEndpoints(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkEndpointGroupsClient) Close
func (c *NetworkEndpointGroupsClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*NetworkEndpointGroupsClient) Connection (deprecated)
func (c *NetworkEndpointGroupsClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*NetworkEndpointGroupsClient) Delete
func (c *NetworkEndpointGroupsClient) Delete(ctx context.Context, req *computepb.DeleteNetworkEndpointGroupRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified network endpoint group. The network endpoints in the NEG and the VM instances they belong to are not terminated when the NEG is deleted. Note that the NEG cannot be deleted if there are backend services referencing it.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteNetworkEndpointGroupRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkEndpointGroupsClient) DetachNetworkEndpoints
func (c *NetworkEndpointGroupsClient) DetachNetworkEndpoints(ctx context.Context, req *computepb.DetachNetworkEndpointsNetworkEndpointGroupRequest, opts ...gax.CallOption) (*Operation, error)
DetachNetworkEndpoints detach a list of network endpoints from the specified network endpoint group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DetachNetworkEndpointsNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DetachNetworkEndpointsNetworkEndpointGroupRequest.
}
op, err := c.DetachNetworkEndpoints(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkEndpointGroupsClient) Get
func (c *NetworkEndpointGroupsClient) Get(ctx context.Context, req *computepb.GetNetworkEndpointGroupRequest, opts ...gax.CallOption) (*computepb.NetworkEndpointGroup, error)
Get returns the specified network endpoint group.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetNetworkEndpointGroupRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkEndpointGroupsClient) Insert
func (c *NetworkEndpointGroupsClient) Insert(ctx context.Context, req *computepb.InsertNetworkEndpointGroupRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a network endpoint group in the specified project using the parameters that are included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#InsertNetworkEndpointGroupRequest.
}
op, err := c.Insert(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkEndpointGroupsClient) List
func (c *NetworkEndpointGroupsClient) List(ctx context.Context, req *computepb.ListNetworkEndpointGroupsRequest, opts ...gax.CallOption) *NetworkEndpointGroupIterator
List retrieves the list of network endpoint groups that are located in the specified project and zone.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListNetworkEndpointGroupsRequest.
}
it := c.List(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkEndpointGroupList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListNetworkEndpointGroupsRequest.
}
for resp, err := range c.List(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*NetworkEndpointGroupsClient) ListNetworkEndpoints
func (c *NetworkEndpointGroupsClient) ListNetworkEndpoints(ctx context.Context, req *computepb.ListNetworkEndpointsNetworkEndpointGroupsRequest, opts ...gax.CallOption) *NetworkEndpointWithHealthStatusIterator
ListNetworkEndpoints lists the network endpoints in the specified network endpoint group.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListNetworkEndpointsNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListNetworkEndpointsNetworkEndpointGroupsRequest.
}
it := c.ListNetworkEndpoints(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkEndpointGroupsListNetworkEndpoints)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.ListNetworkEndpointsNetworkEndpointGroupsRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#ListNetworkEndpointsNetworkEndpointGroupsRequest.
}
for resp, err := range c.ListNetworkEndpoints(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*NetworkEndpointGroupsClient) TestIamPermissions
func (c *NetworkEndpointGroupsClient) TestIamPermissions(ctx context.Context, req *computepb.TestIamPermissionsNetworkEndpointGroupRequest, opts ...gax.CallOption) (*computepb.TestPermissionsResponse, error)
TestIamPermissions returns permissions that a caller has on the specified resource.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkEndpointGroupsRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.TestIamPermissionsNetworkEndpointGroupRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#TestIamPermissionsNetworkEndpointGroupRequest.
}
resp, err := c.TestIamPermissions(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
NetworkEndpointGroupsScopedListPair
type NetworkEndpointGroupsScopedListPair struct {
Key string
Value *computepb.NetworkEndpointGroupsScopedList
}
NetworkEndpointGroupsScopedListPair is a holder type for string/*computepb.NetworkEndpointGroupsScopedList map entries
NetworkEndpointGroupsScopedListPairIterator
type NetworkEndpointGroupsScopedListPairIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []NetworkEndpointGroupsScopedListPair, nextPageToken string, err error)
// contains filtered or unexported fields
}
NetworkEndpointGroupsScopedListPairIterator manages a stream of NetworkEndpointGroupsScopedListPair.
func (*NetworkEndpointGroupsScopedListPairIterator) All
func (it *NetworkEndpointGroupsScopedListPairIterator) All() iter.Seq2[NetworkEndpointGroupsScopedListPair, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*NetworkEndpointGroupsScopedListPairIterator) Next
func (it *NetworkEndpointGroupsScopedListPairIterator) Next() (NetworkEndpointGroupsScopedListPair, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*NetworkEndpointGroupsScopedListPairIterator) PageInfo
func (it *NetworkEndpointGroupsScopedListPairIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
NetworkEndpointWithHealthStatusIterator
type NetworkEndpointWithHealthStatusIterator struct {
// Response is the raw response for the current page.
// It must be cast to the RPC response type.
// Calling Next() or InternalFetch() updates this value.
Response interface{}
// InternalFetch is for use by the Google Cloud Libraries only.
// It is not part of the stable interface of this package.
//
// InternalFetch returns results from a single call to the underlying RPC.
// The number of results is no greater than pageSize.
// If there are no more results, nextPageToken is empty and err is nil.
InternalFetch func(pageSize int, pageToken string) (results []*computepb.NetworkEndpointWithHealthStatus, nextPageToken string, err error)
// contains filtered or unexported fields
}
NetworkEndpointWithHealthStatusIterator manages a stream of *computepb.NetworkEndpointWithHealthStatus.
func (*NetworkEndpointWithHealthStatusIterator) All
func (it *NetworkEndpointWithHealthStatusIterator) All() iter.Seq2[*computepb.NetworkEndpointWithHealthStatus, error]
All returns an iterator. If an error is returned by the iterator, the iterator will stop after that iteration.
func (*NetworkEndpointWithHealthStatusIterator) Next
func (it *NetworkEndpointWithHealthStatusIterator) Next() (*computepb.NetworkEndpointWithHealthStatus, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*NetworkEndpointWithHealthStatusIterator) PageInfo
func (it *NetworkEndpointWithHealthStatusIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the [google.golang.org/api/iterator] package for details.
NetworkFirewallPoliciesCallOptions
type NetworkFirewallPoliciesCallOptions struct {
AddAssociation []gax.CallOption
AddPacketMirroringRule []gax.CallOption
AddRule []gax.CallOption
AggregatedList []gax.CallOption
CloneRules []gax.CallOption
Delete []gax.CallOption
Get []gax.CallOption
GetAssociation []gax.CallOption
GetIamPolicy []gax.CallOption
GetPacketMirroringRule []gax.CallOption
GetRule []gax.CallOption
Insert []gax.CallOption
List []gax.CallOption
Patch []gax.CallOption
PatchPacketMirroringRule []gax.CallOption
PatchRule []gax.CallOption
RemoveAssociation []gax.CallOption
RemovePacketMirroringRule []gax.CallOption
RemoveRule []gax.CallOption
SetIamPolicy []gax.CallOption
TestIamPermissions []gax.CallOption
}
NetworkFirewallPoliciesCallOptions contains the retry settings for each method of NetworkFirewallPoliciesClient.
NetworkFirewallPoliciesClient
type NetworkFirewallPoliciesClient struct {
// The call options for this service.
CallOptions *NetworkFirewallPoliciesCallOptions
// contains filtered or unexported fields
}
NetworkFirewallPoliciesClient is a client for interacting with Google Compute Engine API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.
The NetworkFirewallPolicies API.
func NewNetworkFirewallPoliciesRESTClient
func NewNetworkFirewallPoliciesRESTClient(ctx context.Context, opts ...option.ClientOption) (*NetworkFirewallPoliciesClient, error)
NewNetworkFirewallPoliciesRESTClient creates a new network firewall policies rest client.
The NetworkFirewallPolicies API.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
// TODO: Use client.
_ = c
}
func (*NetworkFirewallPoliciesClient) AddAssociation
func (c *NetworkFirewallPoliciesClient) AddAssociation(ctx context.Context, req *computepb.AddAssociationNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
AddAssociation inserts an association for the specified firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddAssociationNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddAssociationNetworkFirewallPolicyRequest.
}
op, err := c.AddAssociation(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkFirewallPoliciesClient) AddPacketMirroringRule
func (c *NetworkFirewallPoliciesClient) AddPacketMirroringRule(ctx context.Context, req *computepb.AddPacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
AddPacketMirroringRule inserts a packet mirroring rule into a firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddPacketMirroringRuleNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddPacketMirroringRuleNetworkFirewallPolicyRequest.
}
op, err := c.AddPacketMirroringRule(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkFirewallPoliciesClient) AddRule
func (c *NetworkFirewallPoliciesClient) AddRule(ctx context.Context, req *computepb.AddRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
AddRule inserts a rule into a firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AddRuleNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AddRuleNetworkFirewallPolicyRequest.
}
op, err := c.AddRule(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkFirewallPoliciesClient) AggregatedList
func (c *NetworkFirewallPoliciesClient) AggregatedList(ctx context.Context, req *computepb.AggregatedListNetworkFirewallPoliciesRequest, opts ...gax.CallOption) *FirewallPoliciesScopedListPairIterator
AggregatedList retrieves an aggregated list of network firewall policies, listing network firewall policies from all applicable scopes (global and regional) and grouping the results per scope. To prevent failure, Google recommends that you set the returnPartialSuccess parameter to true.
Examples
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
"google.golang.org/api/iterator"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListNetworkFirewallPoliciesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListNetworkFirewallPoliciesRequest.
}
it := c.AggregatedList(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
// If you need to access the underlying RPC response,
// you can do so by casting the `Response` as below.
// Otherwise, remove this line. Only populated after
// first call to Next(). Not safe for concurrent access.
_ = it.Response.(*computepb.NetworkFirewallPolicyAggregatedList)
}
}
all
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.AggregatedListNetworkFirewallPoliciesRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#AggregatedListNetworkFirewallPoliciesRequest.
}
for resp, err := range c.AggregatedList(ctx, req).All() {
if err != nil {
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
}
// TODO: Use resp.
_ = resp
}
}
func (*NetworkFirewallPoliciesClient) CloneRules
func (c *NetworkFirewallPoliciesClient) CloneRules(ctx context.Context, req *computepb.CloneRulesNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
CloneRules copies rules to the specified firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.CloneRulesNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#CloneRulesNetworkFirewallPolicyRequest.
}
op, err := c.CloneRules(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkFirewallPoliciesClient) Close
func (c *NetworkFirewallPoliciesClient) Close() error
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*NetworkFirewallPoliciesClient) Connection (deprecated)
func (c *NetworkFirewallPoliciesClient) Connection() *grpc.ClientConn
Connection returns a connection to the API service.
Deprecated: Connections are now pooled so this method does not always return the same resource.
func (*NetworkFirewallPoliciesClient) Delete
func (c *NetworkFirewallPoliciesClient) Delete(ctx context.Context, req *computepb.DeleteNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
Delete deletes the specified policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.DeleteNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#DeleteNetworkFirewallPolicyRequest.
}
op, err := c.Delete(ctx, req)
if err != nil {
// TODO: Handle error.
}
err = op.Wait(ctx)
if err != nil {
// TODO: Handle error.
}
}
func (*NetworkFirewallPoliciesClient) Get
func (c *NetworkFirewallPoliciesClient) Get(ctx context.Context, req *computepb.GetNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicy, error)
Get returns the specified network firewall policy.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetNetworkFirewallPolicyRequest.
}
resp, err := c.Get(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkFirewallPoliciesClient) GetAssociation
func (c *NetworkFirewallPoliciesClient) GetAssociation(ctx context.Context, req *computepb.GetAssociationNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyAssociation, error)
GetAssociation gets an association with the specified name.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetAssociationNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetAssociationNetworkFirewallPolicyRequest.
}
resp, err := c.GetAssociation(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkFirewallPoliciesClient) GetIamPolicy
func (c *NetworkFirewallPoliciesClient) GetIamPolicy(ctx context.Context, req *computepb.GetIamPolicyNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.Policy, error)
GetIamPolicy gets the access control policy for a resource. May be empty if no such policy or resource exists.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetIamPolicyNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetIamPolicyNetworkFirewallPolicyRequest.
}
resp, err := c.GetIamPolicy(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkFirewallPoliciesClient) GetPacketMirroringRule
func (c *NetworkFirewallPoliciesClient) GetPacketMirroringRule(ctx context.Context, req *computepb.GetPacketMirroringRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error)
GetPacketMirroringRule gets a packet mirroring rule of the specified priority.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetPacketMirroringRuleNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetPacketMirroringRuleNetworkFirewallPolicyRequest.
}
resp, err := c.GetPacketMirroringRule(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkFirewallPoliciesClient) GetRule
func (c *NetworkFirewallPoliciesClient) GetRule(ctx context.Context, req *computepb.GetRuleNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*computepb.FirewallPolicyRule, error)
GetRule gets a rule of the specified priority.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.GetRuleNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields.
// See https://pkg.go.dev/cloud.google.com/go/compute/apiv1/computepb#GetRuleNetworkFirewallPolicyRequest.
}
resp, err := c.GetRule(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*NetworkFirewallPoliciesClient) Insert
func (c *NetworkFirewallPoliciesClient) Insert(ctx context.Context, req *computepb.InsertNetworkFirewallPolicyRequest, opts ...gax.CallOption) (*Operation, error)
Insert creates a new policy in the specified project using the data included in the request.
Example
package main
import (
"context"
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
)
func main() {
ctx := context.Background()
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in:
// https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
c, err := compute.NewNetworkFirewallPoliciesRESTClient(ctx)
if err != nil {
// TODO: Handle error.
}
defer c.Close()
req := &computepb.InsertNetworkFirewallPolicyRequest{
// TODO: Fill request struct fields