Update pool (v1)

Update the network configuration for an existing pool.

Code sample

Go

To learn how to install and use the client library for Live Stream API, see Live Stream API client libraries. For more information, see the Live Stream API Go API reference documentation.

To authenticate to Live Stream API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import (
	"context"
	"fmt"
	"io"

	livestream "cloud.google.com/go/video/livestream/apiv1"
	"cloud.google.com/go/video/livestream/apiv1/livestreampb"
	"google.golang.org/protobuf/types/known/fieldmaskpb"
)

// updatePool updates the network configuration for a Livestream pool.
func updatePool(ctx context.Context, w io.Writer, projectID string, locationID string, poolID string, networkID string) error {
	pool := &livestreampb.Pool{
		Name: fmt.Sprintf("projects/%s/locations/%s/pools/%s", projectID, locationID, poolID),
		NetworkConfig: &livestreampb.Pool_NetworkConfig{
			PeeredNetwork: networkID,
		},
	}
	updateMask := &fieldmaskpb.FieldMask{
		Paths: []string{"network_config"},
	}

	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient failed: %w", err)
	}
	defer client.Close()

	req := &livestreampb.UpdatePoolRequest{
		Pool:       pool,
		UpdateMask: updateMask,
	}

	op, err := client.UpdatePool(ctx, req)
	if err != nil {
		return fmt.Errorf("UpdatePool failed: %w", err)
	}

	response, err := op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("Wait failed: %w", err)
	}

	fmt.Fprintf(w, "Updated pool: %s\n", response.GetName())

	return nil
}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.