Get input (v1)

Get an existing input resource.

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"
	livestreampb "cloud.google.com/go/video/livestream/apiv1/livestreampb"
)

// getInput retrieves an input resource.
func getInput(ctx context.Context, w io.Writer, projectID string, locationID string, inputID string) error {
	name := fmt.Sprintf("projects/%s/locations/%s/inputs/%s", projectID, locationID, inputID)

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

	req := &livestreampb.GetInputRequest{
		Name: name,
	}

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

	fmt.Fprintf(w, "Input: %v\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.