List events (v1)

List all events for a channel.

Code sample

Java

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 Java 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 com.google.cloud.video.livestream.v1.ChannelName;
import com.google.cloud.video.livestream.v1.Event;
import com.google.cloud.video.livestream.v1.LivestreamServiceClient;
import java.io.IOException;

public class ListEvents {

  public static void main(String[] args) throws IOException {
    String projectId = "example-project-id";
    String locationId = "example-location-id";
    String channelId = "example-channel-id";
    listEvents(projectId, locationId, channelId);
  }

  public static void listEvents(String projectId, String locationId, 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.
    try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) {
      String parent = ChannelName.of(projectId, locationId, channelId).toString();

      for (Event event : livestreamServiceClient.listEvents(parent).iterateAll()) {
        System.out.println("Event: " + event.getName());
        System.out.println("State: " + event.getState());
      }
    }
  }
}

What's next

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