Elenco chiavi CDN

Elenco di tutte le risorse chiave CDN stitching video per una località.

Per saperne di più

Per la documentazione dettagliata che include questo esempio di codice, vedi quanto segue:

Esempio di codice

C#

Prima di provare questo esempio, segui le istruzioni di configurazione di C# riportate nella guida rapida dell'API Video Stitcher sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Video Stitcher C#.

Per eseguire l'autenticazione all'API Video Stitcher, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Video.Stitcher.V1;

public class ListCdnKeysSample
{
    public PagedEnumerable<ListCdnKeysResponse, CdnKey> ListCdnKeys(
        string projectId, string regionId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        ListCdnKeysRequest request = new ListCdnKeysRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation(projectId, regionId)
        };

        // Make the request.
        PagedEnumerable<ListCdnKeysResponse, CdnKey> response = client.ListCdnKeys(request);

        // Return the result.
        return response;
    }
}

Go

Prima di provare questo esempio, segui le istruzioni di configurazione di Go riportate nella guida rapida dell'API Video Stitcher sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Video Stitcher Go.

Per eseguire l'autenticazione all'API Video Stitcher, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
	"google.golang.org/api/iterator"
)

// listCDNKeys gets all of the CDN keys for a given location.
func listCDNKeys(w io.Writer, projectID string) error {
	// projectID := "my-project-id"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.ListCdnKeysRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
	}

	it := client.ListCdnKeys(ctx, req)
	fmt.Fprintln(w, "CDN keys:")
	for {
		response, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("it.Next(): %w", err)
		}
		fmt.Fprintln(w, response.GetName())
	}

	return nil
}

Java

Prima di provare questo esempio, segui le istruzioni di configurazione di Java riportate nella guida rapida dell'API Video Stitcher sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Video Stitcher Java.

Per eseguire l'autenticazione all'API Video Stitcher, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


import com.google.cloud.video.stitcher.v1.CdnKey;
import com.google.cloud.video.stitcher.v1.ListCdnKeysRequest;
import com.google.cloud.video.stitcher.v1.LocationName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;

public class ListCdnKeys {

  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";

    listCdnKeys(projectId, location);
  }

  public static void listCdnKeys(String projectId, String location) 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 (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      ListCdnKeysRequest listCdnKeysRequest =
          ListCdnKeysRequest.newBuilder()
              .setParent(LocationName.of(projectId, location).toString())
              .build();

      VideoStitcherServiceClient.ListCdnKeysPagedResponse response =
          videoStitcherServiceClient.listCdnKeys(listCdnKeysRequest);
      System.out.println("CDN keys:");

      for (CdnKey cdnKey : response.iterateAll()) {
        System.out.println(cdnKey.getName());
      }
    }
  }
}

Node.js

Prima di provare questo esempio, segui le istruzioni di configurazione di Node.js riportate nella guida rapida dell'API Video Stitcher sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Video Stitcher Node.js.

Per eseguire l'autenticazione all'API Video Stitcher, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

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

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function listCdnKeys() {
  const iterable = await stitcherClient.listCdnKeysAsync({
    parent: stitcherClient.locationPath(projectId, location),
  });
  console.info('CDN keys:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listCdnKeys();

PHP

Prima di provare questo esempio, segui le istruzioni di configurazione di PHP riportate nella guida rapida dell'API Video Stitcher sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Video Stitcher PHP.

Per eseguire l'autenticazione all'API Video Stitcher, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\ListCdnKeysRequest;

/**
 * Lists all CDN keys for a location.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the CDN keys
 */
function list_cdn_keys(
    string $callingProjectId,
    string $location
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $parent = $stitcherClient->locationName($callingProjectId, $location);
    $request = (new ListCdnKeysRequest())
        ->setParent($parent);
    $response = $stitcherClient->listCdnKeys($request);

    // Print the CDN key list.
    $cdn_keys = $response->iterateAllElements();
    print('CDN keys:' . PHP_EOL);
    foreach ($cdn_keys as $key) {
        printf('%s' . PHP_EOL, $key->getName());
    }
}

Python

Prima di provare questo esempio, segui le istruzioni di configurazione di Python riportate nella guida rapida dell'API Video Stitcher sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Video Stitcher Python.

Per eseguire l'autenticazione all'API Video Stitcher, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.


import argparse

from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    pagers,
    VideoStitcherServiceClient,
)

def list_cdn_keys(project_id: str, location: str) -> pagers.ListCdnKeysPager:
    """Lists all CDN keys in a location.
    Args:
        project_id: The GCP project ID.
        location: The location of the CDN keys.

    Returns:
        An iterable object containing CDN key resources.
    """

    client = VideoStitcherServiceClient()

    parent = f"projects/{project_id}/locations/{location}"
    response = client.list_cdn_keys(parent=parent)
    print("CDN keys:")
    for cdn_key in response.cdn_keys:
        print({cdn_key.name})

    return response

Ruby

Prima di provare questo esempio, segui le istruzioni di configurazione di Ruby riportate nella guida rapida dell'API Video Stitcher sull'utilizzo delle librerie client. Per maggiori informazioni, consulta la documentazione di riferimento dell'API Video Stitcher Ruby.

Per eseguire l'autenticazione all'API Video Stitcher, configura Credenziali predefinite dell'applicazione. Per maggiori informazioni, consulta Configurare l'autenticazione per un ambiente di sviluppo locale.

require "google/cloud/video/stitcher"

##
# List CDN keys for a given location
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
#
def list_cdn_keys project_id:, location:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the parent.
  parent = client.location_path project: project_id, location: location

  response = client.list_cdn_keys parent: parent

  puts "CDN keys:"
  # Print out all CDN keys.
  response.each do |cdn_key|
    puts cdn_key.name
  end
end

Passaggi successivi

Per cercare e filtrare esempi di codice per altri prodotti Google Cloud, consulta il browser di esempio Google Cloud.