チャネル イベントの作成と管理

このページでは、Live Stream API チャネル イベントを作成、管理する方法を説明します。チャネル イベントは、チャネルのサブリソースです。チャネル イベントを使用すると、チャネルを停止せずに、チャネル リソースに対してオペレーションを実行できます。

Google Cloud プロジェクトと認証の設定

Google Cloud プロジェクトと認証情報を作成していない場合は、始める前にをご覧ください。

前提条件

チャネル イベントを作成する前に、次のリソースを作成する必要があります。

  1. 入力エンドポイントを作成する

  2. チャネルを作成する

チャネル イベントを作成する

チャネル イベントを作成する前に、必ずチャネルを開始してください。

チャネル イベントを作成するには、projects.locations.channels.events.create メソッドを使用します。次のイベントタイプがサポートされています。

イベントはすぐに実行することも、後で実行するようにスケジュールすることもできます。

Live Stream API は、チャネル イベントが実行されてから 7 日後にイベントを自動的に削除します。この削除には、失敗したイベントが含まれます。

ミッドロール挿入点イベント

adBreak オブジェクトを使用して、新しい広告の機会を挿入します。

プログラム に戻るイベントを使用して、ミッドロール挿入点からライブ ストリームに戻ります。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。
  • EVENT_ID: イベントのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/EVENT_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "adBreak": {
    "duration": "100s"
  },
  "executeNow": true,
  "state": "PENDING"
}

C#

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の C# API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


using Google.Cloud.Video.LiveStream.V1;

public class CreateChannelEventSample
{
    public Event CreateChannelEvent(
         string projectId, string locationId, string channelId, string eventId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        CreateEventRequest request = new CreateEventRequest
        {
            ParentAsChannelName = ChannelName.FromProjectLocationChannel(projectId, locationId, channelId),
            EventId = eventId,
            Event = new Event
            {
                AdBreak = new Event.Types.AdBreakTask
                {
                    Duration = new Google.Protobuf.WellKnownTypes.Duration
                    {
                        Seconds = 30
                    }
                },
                ExecuteNow = true
            }
        };

        // Make the request.
        Event response = client.CreateEvent(request);
        return response;
    }
}

Go

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Go API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"fmt"
	"io"

	"github.com/golang/protobuf/ptypes/duration"

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

// createChannelEvent creates a channel event. An event is a sub-resource of a
// channel, which can be scheduled by the user to execute operations on a
// channel resource without having to stop the channel. This sample creates an
// ad break event.
func createChannelEvent(w io.Writer, projectID, location, channelID, eventID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// channelID := "my-channel"
	// eventID := "my-channel-event"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.CreateEventRequest{
		Parent:  fmt.Sprintf("projects/%s/locations/%s/channels/%s", projectID, location, channelID),
		EventId: eventID,
		Event: &livestreampb.Event{
			Task: &livestreampb.Event_AdBreak{
				AdBreak: &livestreampb.Event_AdBreakTask{
					Duration: &duration.Duration{
						Seconds: 30,
					},
				},
			},
			ExecuteNow: true,
		},
	}
	// Creates the channel event.
	response, err := client.CreateEvent(ctx, req)
	if err != nil {
		return fmt.Errorf("CreateEvent: %w", err)
	}

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

Java

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Java API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import com.google.cloud.video.livestream.v1.ChannelName;
import com.google.cloud.video.livestream.v1.CreateEventRequest;
import com.google.cloud.video.livestream.v1.Event;
import com.google.cloud.video.livestream.v1.Event.AdBreakTask;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import com.google.protobuf.Duration;
import java.io.IOException;

public class CreateChannelEvent {

  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 channelId = "my-channel-id";
    String eventId = "my-channel-event-id";

    createChannelEvent(projectId, location, channelId, eventId);
  }

  public static void createChannelEvent(
      String projectId, String location, String channelId, String eventId) 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()) {
      var createEventRequest =
          CreateEventRequest.newBuilder()
              .setParent(ChannelName.of(projectId, location, channelId).toString())
              .setEventId(eventId)
              .setEvent(
                  Event.newBuilder()
                      .setAdBreak(
                          AdBreakTask.newBuilder()
                              .setDuration(Duration.newBuilder().setSeconds(30).build())
                              .build())
                      .setExecuteNow(true)
                      .build())
              .build();

      Event response = livestreamServiceClient.createEvent(createEventRequest);
      System.out.println("Channel event: " + response.getName());
    }
  }
}

Node.js

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Node.js API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

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

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

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

async function createChannelEvent() {
  // Construct request
  const request = {
    parent: livestreamServiceClient.channelPath(
      projectId,
      location,
      channelId
    ),
    eventId: eventId,
    event: {
      adBreak: {
        duration: {
          seconds: 30,
        },
      },
      executeNow: true,
    },
  };

  // Run request
  const [event] = await livestreamServiceClient.createEvent(request);
  console.log(`Channel event: ${event.name}`);
}

createChannelEvent();

PHP

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の PHP API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

use Google\Cloud\Video\LiveStream\V1\Event;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\CreateEventRequest;
use Google\Protobuf\Duration;

/**
 * Creates a channel event. This particular sample inserts an ad break marker.
 * Other event types are supported.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the channel
 * @param string  $channelId          The ID of the channel
 * @param string  $eventId            The ID of the channel event
 */
function create_channel_event(
    string $callingProjectId,
    string $location,
    string $channelId,
    string $eventId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();

    $parent = $livestreamClient->channelName($callingProjectId, $location, $channelId);

    $eventAdBreak = (new Event\AdBreakTask())
        ->setDuration(new Duration(['seconds' => 30]));
    $event = (new Event())
        ->setAdBreak($eventAdBreak)
        ->setExecuteNow(true);

    // Run the channel event creation request.
    $request = (new CreateEventRequest())
        ->setParent($parent)
        ->setEvent($event)
        ->setEventId($eventId);
    $response = $livestreamClient->createEvent($request);
    // Print results.
    printf('Channel event: %s' . PHP_EOL, $response->getName());
}

Python

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Python API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import argparse

from google.cloud.video import live_stream_v1
from google.cloud.video.live_stream_v1.services.livestream_service import (
    LivestreamServiceClient,
)
from google.protobuf import duration_pb2 as duration

def create_channel_event(
    project_id: str, location: str, channel_id: str, event_id: str
) -> live_stream_v1.types.Event:
    """Creates a channel event.
    Args:
        project_id: The GCP project ID.
        location: The location of the channel.
        channel_id: The user-defined channel ID.
        event_id: The user-defined event ID."""

    client = LivestreamServiceClient()
    parent = f"projects/{project_id}/locations/{location}/channels/{channel_id}"
    name = f"projects/{project_id}/locations/{location}/channels/{channel_id}/events/{event_id}"

    event = live_stream_v1.types.Event(
        name=name,
        ad_break=live_stream_v1.types.Event.AdBreakTask(
            duration=duration.Duration(
                seconds=30,
            ),
        ),
        execute_now=True,
    )

    response = client.create_event(parent=parent, event=event, event_id=event_id)
    print(f"Channel event: {response.name}")

    return response

Ruby

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Ruby API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/video/live_stream"

##
# Create a channel event
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param channel_id [String] Your channel name (e.g. "my-channel")
# @param event_id [String] Your event name (e.g. "my-event")
#
def create_channel_event project_id:, location:, channel_id:, event_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the parent.
  parent = client.channel_path project: project_id, location: location, channel: channel_id

  # Set the event fields.
  new_event = {
    ad_break: {
      duration: {
        seconds: 100
      }
    },
    execute_now: true
  }

  response = client.create_event parent: parent, event: new_event, event_id: event_id

  # Print the channel event name.
  puts "Channel event: #{response.name}"
end

スレート イベントを挿入する

slate オブジェクトを使用して、ライブ ストリームにスレートを挿入する

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。
  • EVENT_ID: イベントのユーザー定義の識別子。
  • ASSET_ID: スレート アセットのユーザー定義の識別子

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/EVENT_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "slate": {
    "duration": "60s",
    "asset": "projects/PROJECT_NUMBER/locations/LOCATION/assets/ASSET_ID"
  },
  "executeNow": "true",
  "state": "PENDING"
}

プログラムに戻るイベント

returnToProgram オブジェクトを使用して、実行中のすべての adBreak イベントを停止します。これらのイベントをすぐに停止できます。また、executionTime フィールドを使用して後での停止をスケジュールすることもできます。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。
  • EVENT_ID: イベントのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/EVENT_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "executeNow": true,
  "state": "PENDING",
  "returnToProgram": {}
}

ミュート イベント

mute オブジェクトを使用してライブ ストリームをミュートします。ストリームをミュートする時間を指定したり、ミュート解除イベントが実行されるまでストリームをミュートしたりできます。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。
  • EVENT_ID: イベントのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/EVENT_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "mute": {
    "duration": "30s"
  },
  "executeNow": true,
  "state": "PENDING"
}

ミュート解除イベント

unmute オブジェクトを使用してライブ ストリームのミュートを解除します(つまり音声を復元します)。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。
  • EVENT_ID: イベントのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/EVENT_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "unmute": {},
  "executeNow": true,
  "state": "PENDING"
}

入力切り替えイベント

inputSwitch オブジェクトを使用して、チャネル入力を手動で切り替えます。追加の入力でチャネルを作成する方法については、バックアップ入力ストリームを使用してチャネルを作成するをご覧ください。

入力を手動で切り替えると、InputSwitchModeMANUAL に変わります。バックアップ入力ストリームが指定された入力ストリームの automaticFailover フィールドによって構成されている場合でも、指定された入力ストリームが常に使用されます。自動フェイルオーバーが無効になっているため、指定した入力ストリームが切断された場合、チャンネルはバックアップ入力ストリームに切り替わりません。フェイルオーバーを再度有効にするには、自動フェイルオーバーを有効にするをご覧ください。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。
  • EVENT_ID: イベントのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/EVENT_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "inputSwitch": {
    "inputKey": "input-backup"
  },
  "executeNow": true,
  "state": "PENDING"
}

自動フェイルオーバーを有効にする

入力を手動で切り替えた後に自動フェイルオーバーを有効にするには、次の手順を行います。

  1. チャネルを停止する
  2. InputSwitchMode チャネル フィールドを FAILOVER_PREFER_PRIMARY に更新する
  3. チャネルを開始する

チャネル イベントの詳細情報を取得する

チャネル イベントの詳細を取得するには、projects.locations.channels.events.get メソッドを使用します。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。
  • EVENT_ID: イベントのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/EVENT_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "adBreak": {
    "duration": "10s"
  },
  "executeNow": true,
  "state": "SCHEDULED"
}

C#

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の C# API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


using Google.Cloud.Video.LiveStream.V1;

public class GetChannelEventSample
{
    public Event GetChannelEvent(
         string projectId, string locationId, string channelId, string eventId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        GetEventRequest request = new GetEventRequest
        {
            EventName = EventName.FromProjectLocationChannelEvent(projectId, locationId, channelId, eventId),
        };

        // Make the request.
        Event response = client.GetEvent(request);
        return response;
    }
}

Go

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Go API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"fmt"
	"io"

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

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

	req := &livestreampb.GetEventRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/channels/%s/events/%s", projectID, location, channelID, eventID),
	}

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

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

Java

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Java API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import com.google.cloud.video.livestream.v1.Event;
import com.google.cloud.video.livestream.v1.EventName;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;

public class GetChannelEvent {

  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 channelId = "my-channel-id";
    String eventId = "my-channel-event-id";

    getChannelEvent(projectId, location, channelId, eventId);
  }

  public static void getChannelEvent(
      String projectId, String location, String channelId, String eventId) 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()) {
      EventName name = EventName.of(projectId, location, channelId, eventId);
      Event response = livestreamServiceClient.getEvent(name);
      System.out.println("Channel event: " + response.getName());
    }
  }
}

Node.js

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Node.js API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

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

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

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

async function getChannelEvent() {
  // Construct request
  const request = {
    name: livestreamServiceClient.eventPath(
      projectId,
      location,
      channelId,
      eventId
    ),
  };
  const [event] = await livestreamServiceClient.getEvent(request);
  console.log(`Channel event: ${event.name}`);
}

getChannelEvent();

PHP

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の PHP API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

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

/**
 * Gets a channel event.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the channel
 * @param string  $channelId          The ID of the channel
 * @param string  $eventId            The ID of the channel event
 */
function get_channel_event(
    string $callingProjectId,
    string $location,
    string $channelId,
    string $eventId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();
    $formattedName = $livestreamClient->eventName($callingProjectId, $location, $channelId, $eventId);

    // Get the channel event.
    $request = (new GetEventRequest())
        ->setName($formattedName);
    $response = $livestreamClient->getEvent($request);
    printf('Channel event: %s' . PHP_EOL, $response->getName());
}

Python

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Python API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import argparse

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

def get_channel_event(
    project_id: str, location: str, channel_id: str, event_id: str
) -> live_stream_v1.types.Event:
    """Gets a channel.
    Args:
        project_id: The GCP project ID.
        location: The location of the channel.
        channel_id: The user-defined channel ID.
        event_id: The user-defined event ID."""

    client = LivestreamServiceClient()

    name = f"projects/{project_id}/locations/{location}/channels/{channel_id}/events/{event_id}"
    response = client.get_event(name=name)
    print(f"Channel event: {response.name}")

    return response

Ruby

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Ruby API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/video/live_stream"

##
# Get a channel event
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param channel_id [String] Your channel name (e.g. "my-channel")
# @param event_id [String] Your event name (e.g. "my-event")
#
def get_channel_event project_id:, location:, channel_id:, event_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the channel event.
  name = client.event_path project: project_id, location: location, channel: channel_id, event: event_id

  # Get the channel event.
  event = client.get_event name: name

  # Print the channel event name.
  puts "Channel event: #{event.name}"
end

チャネル イベントを一覧表示する

チャネル用に作成したすべてのチャネル イベントを一覧表示するには、projects.locations.channels.events.list メソッドを使用します。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
    "events": [
      {
        "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/my-event",
        "createTime": CREATE_TIME,
        "updateTime": UPDATE_TIME,
        "adBreak": {
          "duration": "10s"
        },
        "executeNow": true,
        "state": "SCHEDULED"
      },
      {
        "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/events/my-event2",
        "createTime": CREATE_TIME,
        "updateTime": UPDATE_TIME,
        "adBreak": {
          "duration": "10s"
        },
        "executeNow": true,
        "state": "SCHEDULED"
      }
  ]
}

C#

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の C# API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


using Google.Api.Gax;
using Google.Cloud.Video.LiveStream.V1;
using System.Collections.Generic;
using System.Linq;

public class ListChannelEventsSample
{
    public IList<Event> ListChannelEvents(
        string projectId, string regionId, string channelId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        ListEventsRequest request = new ListEventsRequest
        {
            ParentAsChannelName = ChannelName.FromProjectLocationChannel(projectId, regionId, channelId)
        };

        // Make the request.
        PagedEnumerable<ListEventsResponse, Event> response = client.ListEvents(request);

        // The returned sequence will lazily perform RPCs as it's being iterated over.
        return response.ToList();
    }
}

Go

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Go API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"fmt"
	"io"

	"google.golang.org/api/iterator"

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

// listChannelEvents lists all channel events for a given channel.
func listChannelEvents(w io.Writer, projectID, location, channelID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// channelID := "my-channel-id"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.ListEventsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s/channels/%s", projectID, location, channelID),
	}

	it := client.ListEvents(ctx, req)
	fmt.Fprintln(w, "Channel events:")

	for {
		response, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListEvents: %w", err)
		}
		fmt.Fprintln(w, response.GetName())
	}
	return nil
}

Java

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Java API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import com.google.cloud.video.livestream.v1.ChannelName;
import com.google.cloud.video.livestream.v1.Event;
import com.google.cloud.video.livestream.v1.ListEventsRequest;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;

public class ListChannelEvents {

  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 channelId = "my-channel-id";

    listChannelEvents(projectId, location, channelId);
  }

  public static void listChannelEvents(String projectId, String location, String channelId)
      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()) {
      var listEventsRequest =
          ListEventsRequest.newBuilder()
              .setParent(ChannelName.of(projectId, location, channelId).toString())
              .build();

      LivestreamServiceClient.ListEventsPagedResponse response =
          livestreamServiceClient.listEvents(listEventsRequest);
      System.out.println("Channel events:");

      for (Event event : response.iterateAll()) {
        System.out.println(event.getName());
      }
    }
  }
}

Node.js

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Node.js API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

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

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

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

async function listChannelEvents() {
  const iterable = await livestreamServiceClient.listEventsAsync({
    parent: livestreamServiceClient.channelPath(
      projectId,
      location,
      channelId
    ),
  });
  console.info('Channel events:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listChannelEvents();

PHP

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の PHP API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

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

/**
 * Lists the channel events for a given channel.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the channel
 * @param string  $channelId          The ID of the channel
 */
function list_channel_events(
    string $callingProjectId,
    string $location,
    string $channelId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();
    $parent = $livestreamClient->channelName($callingProjectId, $location, $channelId);
    $request = (new ListEventsRequest())
        ->setParent($parent);

    $response = $livestreamClient->listEvents($request);
    // Print the channel list.
    $events = $response->iterateAllElements();
    print('Channel events:' . PHP_EOL);
    foreach ($events as $event) {
        printf('%s' . PHP_EOL, $event->getName());
    }
}

Python

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Python API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import argparse

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

def list_channel_events(
    project_id: str, location: str, channel_id: str
) -> pagers.ListEventsPager:
    """Lists all events for a channel.
    Args:
        project_id: The GCP project ID.
        location: The location of the channel.
        channel_id: The user-defined channel ID."""

    client = LivestreamServiceClient()

    parent = f"projects/{project_id}/locations/{location}/channels/{channel_id}"
    page_result = client.list_events(parent=parent)
    print("Events:")

    responses = []
    for response in page_result:
        print(response.name)
        responses.append(response)

    return responses

Ruby

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Ruby API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/video/live_stream"

##
# List the channel events
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param channel_id [String] Your channel name (e.g. "my-channel")
#
def list_channel_events project_id:, location:, channel_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the parent.
  parent = client.channel_path project: project_id, location: location, channel: channel_id

  # Get the list of channel events.
  response = client.list_events parent: parent

  puts "Channel events:"
  # Print out all channel events.
  response.each do |event|
    puts event.name
  end
end

チャネル イベントを削除する

チャネル イベントを削除するには、projects.locations.channels.events.delete メソッドを使用します。

Live Stream API は、チャネル イベントが実行されてから 7 日後にイベントを自動的に削除します。この削除には、失敗したイベントが含まれます。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: チャネルがあるロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: チャネルのユーザー定義の識別子。
  • EVENT_ID: イベントのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{}

C#

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の C# API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


using Google.Cloud.Video.LiveStream.V1;

public class DeleteChannelEventSample
{
    public void DeleteChannelEvent(
         string projectId, string locationId, string channelId, string eventId)
    {
        // Create the client.
        LivestreamServiceClient client = LivestreamServiceClient.Create();

        DeleteEventRequest request = new DeleteEventRequest
        {
            EventName = EventName.FromProjectLocationChannelEvent(projectId, locationId, channelId, eventId),
        };

        // Make the request.
        client.DeleteEvent(request);
    }
}

Go

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Go API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"fmt"
	"io"

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

// deleteChannelEvent deletes a previously-created channel event.
func deleteChannelEvent(w io.Writer, projectID, location, channelID, eventID string) error {
	// projectID := "my-project-id"
	// location := "us-central1"
	// channelID := "my-channel"
	// eventID := "my-channel-event"
	ctx := context.Background()
	client, err := livestream.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("NewClient: %w", err)
	}
	defer client.Close()

	req := &livestreampb.DeleteEventRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/channels/%s/events/%s", projectID, location, channelID, eventID),
	}

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

	fmt.Fprintf(w, "Deleted channel event")
	return nil
}

Java

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Java API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import com.google.cloud.video.livestream.v1.DeleteEventRequest;
import com.google.cloud.video.livestream.v1.EventName;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;

public class DeleteChannelEvent {

  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 channelId = "my-channel-id";
    String eventId = "my-channel-event-id";

    deleteChannelEvent(projectId, location, channelId, eventId);
  }

  public static void deleteChannelEvent(
      String projectId, String location, String channelId, String eventId) 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()) {
      var deleteEventRequest =
          DeleteEventRequest.newBuilder()
              .setName(EventName.of(projectId, location, channelId, eventId).toString())
              .build();

      livestreamServiceClient.deleteEvent(deleteEventRequest);
      System.out.println("Deleted channel event");
    }
  }
}

Node.js

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Node.js API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

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

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

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

async function deleteChannelEvent() {
  // Construct request
  const request = {
    name: livestreamServiceClient.eventPath(
      projectId,
      location,
      channelId,
      eventId
    ),
  };

  // Run request
  await livestreamServiceClient.deleteEvent(request);
  console.log('Deleted channel event');
}

deleteChannelEvent();

PHP

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の PHP API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

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

/**
 * Deletes a channel event.
 *
 * @param string  $callingProjectId   The project ID to run the API call under
 * @param string  $location           The location of the channel
 * @param string  $channelId          The ID of the channel
 * @param string  $eventId            The ID of the channel event to be deleted
 */
function delete_channel_event(
    string $callingProjectId,
    string $location,
    string $channelId,
    string $eventId
): void {
    // Instantiate a client.
    $livestreamClient = new LivestreamServiceClient();
    $formattedName = $livestreamClient->eventName($callingProjectId, $location, $channelId, $eventId);

    // Run the channel event deletion request.
    $request = (new DeleteEventRequest())
        ->setName($formattedName);
    $livestreamClient->deleteEvent($request);
    printf('Deleted channel event %s' . PHP_EOL, $eventId);
}

Python

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Python API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import argparse

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

def delete_channel_event(
    project_id: str, location: str, channel_id: str, event_id: str
) -> None:
    """Deletes a channel event.
    Args:
        project_id: The GCP project ID.
        location: The location of the channel.
        channel_id: The user-defined channel ID.
        event_id: The user-defined event ID."""

    client = LivestreamServiceClient()

    name = f"projects/{project_id}/locations/{location}/channels/{channel_id}/events/{event_id}"
    response = client.delete_event(name=name)
    print("Deleted channel event")

    return response

Ruby

Live Stream API のクライアント ライブラリをインストールして使用する方法については、Live Stream API クライアント ライブラリをご覧ください。詳細については、Live Stream API の Ruby API リファレンス ドキュメントをご覧ください。

Live Stream API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/video/live_stream"

##
# Delete a channel event
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param channel_id [String] Your channel name (e.g. "my-channel")
# @param event_id [String] Your event name (e.g. "my-event")
#
def delete_channel_event project_id:, location:, channel_id:, event_id:
  # Create a Live Stream client.
  client = Google::Cloud::Video::LiveStream.livestream_service

  # Build the resource name of the channel event.
  name = client.event_path project: project_id, location: location, channel: channel_id, event: event_id

  # Delete the channel event.
  client.delete_event name: name

  # Print a success message.
  puts "Deleted channel event"
end