Eingabeendpunkt abrufen

Details zu einer Livestreameingabe-Endpunktressource abrufen.

Weitere Informationen

Eine ausführliche Dokumentation, die dieses Codebeispiel enthält, finden Sie hier:

Codebeispiel

C#

Informationen zum Installieren und Verwenden der Clientbibliothek für die Live Stream API findest du unter Live Stream API-Clientbibliotheken. Weitere Informationen finden Sie in der C# API-Referenzdokumentation zur Live Stream API.

Damit du dich bei der Live Stream API authentifizieren kannst, musst du Standardanmeldedaten für Anwendungen einrichten. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


using Google.Cloud.Video.LiveStream.V1;

public class GetInputSample
{
    public Input GetInput(
         string projectId, string locationId, string inputId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        GetInputRequest request = new GetInputRequest
        {
            InputName = InputName.FromProjectLocationInput(projectId, locationId, inputId)
        };

        // Make the request.
        Input response = client.GetInput(request);
        return response;
    }
}

Go

Informationen zum Installieren und Verwenden der Clientbibliothek für die Live Stream API findest du unter Live Stream API-Clientbibliotheken. Weitere Informationen finden Sie in der Go API-Referenzdokumentation zur Live Stream API.

Damit du dich bei der Live Stream API authentifizieren kannst, musst du Standardanmeldedaten für Anwendungen einrichten. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

import (
	"context"
	"fmt"
	"io"

	livestream "cloud.google.com/go/video/livestream/apiv1"
	"cloud.google.com/go/video/livestream/apiv1/livestreampb"
)

// getInput gets a previously-created input endpoint.
func getInput(w io.Writer, projectID, location, inputID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// inputID := "my-input-id"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.GetInputRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/inputs/%s", projectID, location, inputID),
	}

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

	fmt.Fprintf(w, "Input: %v", response.Name)
	return nil
}

Java

Informationen zum Installieren und Verwenden der Clientbibliothek für die Live Stream API findest du unter Live Stream API-Clientbibliotheken. Weitere Informationen finden Sie in der Java API-Referenzdokumentation zur Live Stream API.

Damit du dich bei der Live Stream API authentifizieren kannst, musst du Standardanmeldedaten für Anwendungen einrichten. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import com.google.cloud.video.livestream.v1.Input;
import com.google.cloud.video.livestream.v1.InputName;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;

public class GetInput {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String inputId = "my-input-id";

    getInput(projectId, location, inputId);
  }

  public static void getInput(String projectId, String location, String inputId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. In this example, try-with-resources is used
    // which automatically calls close() on the client to clean up resources.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
      InputName name = InputName.of(projectId, location, inputId);
      Input response = livestreamServiceClient.getInput(name);
      System.out.println("Input: " + response.getName());
    }
  }
}

Node.js

Informationen zum Installieren und Verwenden der Clientbibliothek für die Live Stream API findest du unter Live Stream API-Clientbibliotheken. Weitere Informationen finden Sie in der Node.js API-Referenzdokumentation zur Live Stream API.

Damit du dich bei der Live Stream API authentifizieren kannst, musst du Standardanmeldedaten für Anwendungen einrichten. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// inputId = 'my-input';

// Imports the Livestream library
const {LivestreamServiceClient} = require('@google-cloud/livestream').v1;

// Instantiates a client
const livestreamServiceClient = new LivestreamServiceClient();

async function getInput() {
  // Construct request
  const request = {
    name: livestreamServiceClient.inputPath(projectId, location, inputId),
  };
  const [input] = await livestreamServiceClient.getInput(request);
  console.log(`Input: ${input.name}`);
}

getInput();

PHP

Informationen zum Installieren und Verwenden der Clientbibliothek für die Live Stream API findest du unter Live Stream API-Clientbibliotheken. Weitere Informationen finden Sie in der PHP API-Referenzdokumentation zur Live Stream API.

Damit du dich bei der Live Stream API authentifizieren kannst, musst du Standardanmeldedaten für Anwendungen einrichten. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\GetInputRequest;

/**
 * Gets an input.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the input
 * @param string  $inputId            The ID of the input
 */
function get_input(
    string $callingProjectId,
    string $location,
    string $inputId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();
    $formattedName = $livestreamClient->inputName($callingProjectId, $location, $inputId);

    // Get the input.
    $request = (new GetInputRequest())
        ->setName($formattedName);
    $response = $livestreamClient->getInput($request);
    // Print results
    printf('Input: %s' . PHP_EOL, $response->getName());
}

Python

Informationen zum Installieren und Verwenden der Clientbibliothek für die Live Stream API findest du unter Live Stream API-Clientbibliotheken. Weitere Informationen finden Sie in der Python API-Referenzdokumentation zur Live Stream API.

Damit du dich bei der Live Stream API authentifizieren kannst, musst du Standardanmeldedaten für Anwendungen einrichten. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import argparse

from google.cloud.video import live_stream_v1
from google.cloud.video.live_stream_v1.services.livestream_service import (
    LivestreamServiceClient,
)

def get_input(
    project_id: str, location: str, input_id: str
) -> live_stream_v1.types.Input:
    """Gets an input.
    Args:
        project_id: The GCP project ID.
        location: The location of the input.
        input_id: The user-defined input ID."""

    client = LivestreamServiceClient()

    name = f"projects/{project_id}/locations/{location}/inputs/{input_id}"
    response = client.get_input(name=name)
    print(f"Input: {response.name}")

    return response

Ruby

Informationen zum Installieren und Verwenden der Clientbibliothek für die Live Stream API findest du unter Live Stream API-Clientbibliotheken. Weitere Informationen finden Sie in der Ruby API-Referenzdokumentation zur Live Stream API.

Damit du dich bei der Live Stream API authentifizieren kannst, musst du Standardanmeldedaten für Anwendungen einrichten. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

require "google/cloud/video/live_stream"

##
# Get an input endpoint
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param input_id [String] Your input name (e.g. "my-input")
#
def get_input project_id:, location:, input_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the input.
  name = client.input_path project: project_id, location: location, input: input_id

  # Get the input.
  input = client.get_input name: name

  # Print the input name.
  puts "Input: #{input.name}"
end

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.