Inspect a VOD session

The Video Stitcher API inserts ads into video assets. The adTagUri field in the body of a VOD session request specifies the URL from where ad metadata is retrieved. The Video Stitcher API also includes user metadata when it makes the request.

The /vodAdTagDetails endpoint contains the following information:

  • resolved ad tag
  • user metadata
  • request body and headers
  • response body and headers

The /vodStitchDetails endpoint contains the following information:

  • ad break ID
  • ad ID
  • ad time offset (in seconds)
  • reason if the ad was not inserted
  • ad media metadata

This page describes how to inspect the ad tag details and stitch details for a given VOD session. For more details, see the REST documentation for VodAdTagDetail and VodStitchDetail. This page does not apply to VOD sessions created for Google Ad Manager (GAM) ad insertion. You can't use the ad tag and stitch details endpoints for these sessions. Use the Stream activity monitor in Ad Manager to see details about ad requests.

Before you begin

Make sure that you're familiar with the steps to create a VOD session.

Suppose that you create a VOD session and receive the following session (some fields omitted):

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/vodSessions/SESSION_ID"
  ...
}

This page assumes the VOD session, as shown above, has already been created.

List ad tag details

To list the ad tag details for a VOD session, use the projects.locations.vodSessions.vodAdTagDetails.list method.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER: your Google Cloud project number located in the Project number field on the IAM Settings page
  • LOCATION: the location of your session; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SESSION_ID: the session ID for the VOD session

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "vodAdTagDetails" : [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/vodSessions/SESSION_ID/vodAdTagDetails/VOD_AD_TAG_DETAILS_ID",
      "adRequests": [
        {
          "uri": "REQUEST_URL",
          "requestMetadata": "AD_TAG_REQUEST_METADATA",
          "responseMetadata": "AD_TAG_RESPONSE_METADATA"
        }
      ]
    }
  ]
}

C#

Before trying this sample, follow the C# setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API C# API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


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

public class ListVodAdTagDetailsSample
{
    public PagedEnumerable<ListVodAdTagDetailsResponse, VodAdTagDetail> ListVodAdTagDetails(
        string projectId, string regionId, string sessionId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        ListVodAdTagDetailsRequest request = new ListVodAdTagDetailsRequest
        {
            ParentAsVodSessionName = VodSessionName.FromProjectLocationVodSession(projectId, regionId, sessionId)
        };

        // Make the request.
        PagedEnumerable<ListVodAdTagDetailsResponse, VodAdTagDetail> response = client.ListVodAdTagDetails(request);

        // Return the result.
        return response;
    }
}

Go

Before trying this sample, follow the Go setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Go API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

// listVodAdTagDetails lists the ad tag details for a video on demand (VOD) session.
func listVodAdTagDetails(w io.Writer, projectID, sessionID string) error {
	// projectID := "my-project-id"
	// sessionID := "123-456-789"
	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.ListVodAdTagDetailsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s/vodSessions/%s", projectID, location, sessionID),
	}

	it := client.ListVodAdTagDetails(ctx, req)
	fmt.Fprintln(w, "VOD ad tag details:")
	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

Before trying this sample, follow the Java setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Java API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import com.google.cloud.video.stitcher.v1.ListVodAdTagDetailsRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodAdTagDetail;
import com.google.cloud.video.stitcher.v1.VodSessionName;
import java.io.IOException;

public class ListVodAdTagDetails {

  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 sessionId = "my-session-id";

    listVodAdTagDetails(projectId, location, sessionId);
  }

  public static void listVodAdTagDetails(String projectId, String location, String sessionId)
      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()) {
      ListVodAdTagDetailsRequest listVodAdTagDetailsRequest =
          ListVodAdTagDetailsRequest.newBuilder()
              .setParent(VodSessionName.of(projectId, location, sessionId).toString())
              .build();

      VideoStitcherServiceClient.ListVodAdTagDetailsPagedResponse response =
          videoStitcherServiceClient.listVodAdTagDetails(listVodAdTagDetailsRequest);
      System.out.println("VOD ad tag details:");

      for (VodAdTagDetail adTagDetail : response.iterateAll()) {
        System.out.println(adTagDetail.toString());
      }
    }
  }
}

Node.js

Before trying this sample, follow the Node.js setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Node.js API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

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

async function listVodAdTagDetails() {
  // Construct request
  const request = {
    parent: stitcherClient.vodSessionPath(projectId, location, sessionId),
  };
  const iterable = await stitcherClient.listVodAdTagDetailsAsync(request);
  console.log('VOD ad tag details:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listVodAdTagDetails();

PHP

Before trying this sample, follow the PHP setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API PHP API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

/**
 * Lists the ad tag details for the specified VOD session.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the session
 * @param string $sessionId            The ID of the session
 */
function list_vod_ad_tag_details(
    string $callingProjectId,
    string $location,
    string $sessionId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->vodSessionName($callingProjectId, $location, $sessionId);
    $request = (new ListVodAdTagDetailsRequest())
        ->setParent($formattedName);
    $response = $stitcherClient->listVodAdTagDetails($request);

    // Print the ad tag details list.
    $adTagDetails = $response->iterateAllElements();
    print('VOD ad tag details:' . PHP_EOL);
    foreach ($adTagDetails as $adTagDetail) {
        printf('%s' . PHP_EOL, $adTagDetail->getName());
    }
}

Python

Before trying this sample, follow the Python setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Python API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import argparse

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


def list_vod_ad_tag_details(
    project_id: str, location: str, session_id: str
) -> pagers.ListVodAdTagDetailsPager:
    """Lists the ad tag details for the specified VOD session.
    Args:
        project_id: The GCP project ID.
        location: The location of the session.
        session_id: The ID of the VOD session.

    Returns:
        An iterable object containing VOD ad tag details resources.
    """

    client = VideoStitcherServiceClient()

    parent = client.vod_session_path(project_id, location, session_id)
    page_result = client.list_vod_ad_tag_details(parent=parent)
    print("VOD ad tag details:")
    for response in page_result:
        print(response)

    return response

Ruby

Before trying this sample, follow the Ruby setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Ruby API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

require "google/cloud/video/stitcher"

##
# List the ad tag details for a VOD session
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param session_id [String] The VOD session ID (e.g. "my-vod-session-id")
#
def list_vod_ad_tag_details project_id:, location:, session_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the parent.
  parent = client.vod_session_path project: project_id, location: location,
                                   vod_session: session_id

  # List all ad tag details for the VOD session.
  response = client.list_vod_ad_tag_details parent: parent

  puts "VOD ad tag details:"
  # Print out all VOD ad tag details.
  response.each do |vod_ad_tag_detail|
    puts vod_ad_tag_detail.name
  end
end

The response returns a list of VodAdTagDetail objects. Each VodAdTagDetail represents the ad retrieval metadata for an ad tag, and each AdRequest represents the ad request metadata for a single ad request.

Additional results

The curl response may include a nextPageToken, which you can use to retrieve additional results:

{
  "vodAdTagDetails": [
    ...
  ],
  "nextPageToken": "NEXT_PAGE_TOKEN"
}

You can send another curl request, including the value of NEXT_PAGE_TOKEN, to list the additional objects. Append the following to the URL in the preceding API call:

?pageToken=NEXT_PAGE_TOKEN

Get ad tag details

To get the details for a single VodAdTagDetail object in a VOD session, use the projects.locations.vodSessions.vodAdTagDetails.get method.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER: your Google Cloud project number located in the Project number field on the IAM Settings page
  • LOCATION: the location of your session; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SESSION_ID: the session ID for the VOD session
  • VOD_AD_TAG_DETAILS_ID: the ID for the VOD ad tag details

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/vodSessions/SESSION_ID/vodAdTagDetails/VOD_AD_TAG_DETAILS_ID",
  "adRequests": [
    {
      "uri": "REQUEST_URL",
      "requestMetadata": "AD_TAG_REQUEST_METADATA",
      "responseMetadata": "AD_TAG_RESPONSE_METADATA"
    }
  ]
}

C#

Before trying this sample, follow the C# setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API C# API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


using Google.Cloud.Video.Stitcher.V1;

public class GetVodAdTagDetailSample
{
    public VodAdTagDetail GetVodAdTagDetail(
        string projectId, string location, string sessionId, string adTagDetailId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        GetVodAdTagDetailRequest request = new GetVodAdTagDetailRequest
        {
            VodAdTagDetailName = VodAdTagDetailName.FromProjectLocationVodSessionVodAdTagDetail(projectId, location, sessionId, adTagDetailId)
        };

        // Call the API.
        VodAdTagDetail vodAdTagDetail = client.GetVodAdTagDetail(request);

        // Return the result.
        return vodAdTagDetail;
    }
}

Go

Before trying this sample, follow the Go setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Go API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// getVodAdTagDetail gets the specified ad tag detail for a video on demand (VOD) session.
func getVodAdTagDetail(w io.Writer, projectID, sessionID, adTagDetailID string) error {
	// projectID := "my-project-id"
	// sessionID := "123-456-789"
	// adTagDetailID := "01234-56789"
	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.GetVodAdTagDetailRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/vodSessions/%s/vodAdTagDetails/%s", projectID, location, sessionID, adTagDetailID),
	}
	// Gets the ad tag detail.
	response, err := client.GetVodAdTagDetail(ctx, req)
	if err != nil {
		return fmt.Errorf("client.GetVodAdTagDetail: %w", err)
	}
	b, err := json.MarshalIndent(response, "", " ")
	if err != nil {
		return fmt.Errorf("json.MarshalIndent: %w", err)
	}

	fmt.Fprintf(w, "VOD ad tag detail:\n%s", string(b))
	return nil
}

Java

Before trying this sample, follow the Java setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Java API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import com.google.cloud.video.stitcher.v1.GetVodAdTagDetailRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodAdTagDetail;
import com.google.cloud.video.stitcher.v1.VodAdTagDetailName;
import java.io.IOException;

public class GetVodAdTagDetail {

  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 sessionId = "my-session-id";
    String adTagDetailId = "my-ad-tag-id";

    getVodAdTagDetail(projectId, location, sessionId, adTagDetailId);
  }

  public static void getVodAdTagDetail(
      String projectId, String location, String sessionId, String adTagDetailId)
      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()) {
      GetVodAdTagDetailRequest getVodAdTagDetailRequest =
          GetVodAdTagDetailRequest.newBuilder()
              .setName(
                  VodAdTagDetailName.of(projectId, location, sessionId, adTagDetailId).toString())
              .build();

      VodAdTagDetail response =
          videoStitcherServiceClient.getVodAdTagDetail(getVodAdTagDetailRequest);
      System.out.println("VOD ad tag detail: " + response.getName());
    }
  }
}

Node.js

Before trying this sample, follow the Node.js setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Node.js API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

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

async function getVodAdTagDetail() {
  // Construct request
  const request = {
    name: stitcherClient.vodAdTagDetailPath(
      projectId,
      location,
      sessionId,
      adTagDetailId
    ),
  };
  const [adTagDetail] = await stitcherClient.getVodAdTagDetail(request);
  console.log(`VOD ad tag detail: ${adTagDetail.name}`);
}

getVodAdTagDetail();

PHP

Before trying this sample, follow the PHP setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API PHP API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

/**
 * Gets the specified ad tag detail for the VOD session.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the session
 * @param string $sessionId            The ID of the session
 * @param string $adTagDetailId        The ID of the ad tag detail
 */
function get_vod_ad_tag_detail(
    string $callingProjectId,
    string $location,
    string $sessionId,
    string $adTagDetailId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->vodAdTagDetailName($callingProjectId, $location, $sessionId, $adTagDetailId);
    $request = (new GetVodAdTagDetailRequest())
        ->setName($formattedName);
    $adTagDetail = $stitcherClient->getVodAdTagDetail($request);

    // Print results
    printf('VOD ad tag detail: %s' . PHP_EOL, $adTagDetail->getName());
}

Python

Before trying this sample, follow the Python setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Python API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import argparse

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


def get_vod_ad_tag_detail(
    project_id: str, location: str, session_id: str, ad_tag_detail_id: str
) -> stitcher_v1.types.VodAdTagDetail:
    """Gets the specified ad tag detail for a VOD session.
    Args:
        project_id: The GCP project ID.
        location: The location of the session.
        session_id: The ID of the VOD session.
        ad_tag_detail_id: The ID of the ad tag details.

    Returns:
        The VOD ad tag detail resource.
    """

    client = VideoStitcherServiceClient()

    name = client.vod_ad_tag_detail_path(
        project_id, location, session_id, ad_tag_detail_id
    )
    response = client.get_vod_ad_tag_detail(name=name)
    print(f"VOD ad tag detail: {response.name}")
    return response

Ruby

Before trying this sample, follow the Ruby setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Ruby API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

require "google/cloud/video/stitcher"

##
# Get the specified ad tag detail for a VOD session
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param session_id [String] The VOD session ID (e.g. "my-vod-session-id")
# @param ad_tag_detail_id [String] The ad tag detail ID (e.g. "my-ad-tag-id")
#
def get_vod_ad_tag_detail project_id:, location:, session_id:, ad_tag_detail_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the VOD ad tag detail.
  name = client.vod_ad_tag_detail_path project: project_id, location: location,
                                       vod_session: session_id,
                                       vod_ad_tag_detail: ad_tag_detail_id

  # Get the VOD ad tag detail.
  ad_tag_detail = client.get_vod_ad_tag_detail name: name

  # Print the VOD ad tag detail name.
  puts "VOD ad tag detail: #{ad_tag_detail.name}"
end

List stitch details

You can view detailed information about the ads that were stitched for any VOD session.

To list the stitch details for a VOD session, use the projects.locations.vodSessions.vodStitchDetails.list method.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER: your Google Cloud project number located in the Project number field on the IAM Settings page
  • LOCATION: the location of your session; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SESSION_ID: the session ID for the VOD session

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "vodStitchDetails" : [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/vodSessions/SESSION_ID/vodStitchDetails/VOD_STITCH_DETAIL_ID",
      "adStitchDetails": [
        {
          "adBreakId": "AD_BREAK_ID",
          "adId": "AD_ID",
          "adTimeOffset": "AD_TIME_OFFSET",
          "skipReason": "SKIP_REASON",
          "media": "MEDIA_OBJECT"
        },
        {
          "adBreakId": "my-other-ad-break-id",
          "adId": "my-other-ad-id",
          "adTimeOffset": "my-other-ad-time-offset",
          "skipReason": "my-other-skip-reason",
          "media": "my-other-media-object"
        }
      ]
    }
  ]
}

C#

Before trying this sample, follow the C# setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API C# API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


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

public class ListVodStitchDetailsSample
{
    public PagedEnumerable<ListVodStitchDetailsResponse, VodStitchDetail> ListVodStitchDetails(
        string projectId, string regionId, string sessionId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        ListVodStitchDetailsRequest request = new ListVodStitchDetailsRequest
        {
            ParentAsVodSessionName = VodSessionName.FromProjectLocationVodSession(projectId, regionId, sessionId)
        };

        // Make the request.
        PagedEnumerable<ListVodStitchDetailsResponse, VodStitchDetail> response = client.ListVodStitchDetails(request);

        // Return the result.
        return response;
    }
}

Go

Before trying this sample, follow the Go setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Go API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

// listVodStitchDetails lists the stitch details for a video on demand (VOD) session.
func listVodStitchDetails(w io.Writer, projectID, sessionID string) error {
	// projectID := "my-project-id"
	// sessionID := "123-456-789"
	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.ListVodStitchDetailsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s/vodSessions/%s", projectID, location, sessionID),
	}

	it := client.ListVodStitchDetails(ctx, req)
	fmt.Fprintln(w, "VOD stitch details:")
	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

Before trying this sample, follow the Java setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Java API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import com.google.cloud.video.stitcher.v1.ListVodStitchDetailsRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodSessionName;
import com.google.cloud.video.stitcher.v1.VodStitchDetail;
import java.io.IOException;

public class ListVodStitchDetails {

  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 sessionId = "my-session-id";

    listVodStitchDetails(projectId, location, sessionId);
  }

  public static void listVodStitchDetails(String projectId, String location, String sessionId)
      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()) {
      ListVodStitchDetailsRequest listVodStitchDetailsRequest =
          ListVodStitchDetailsRequest.newBuilder()
              .setParent(VodSessionName.of(projectId, location, sessionId).toString())
              .build();

      VideoStitcherServiceClient.ListVodStitchDetailsPagedResponse response =
          videoStitcherServiceClient.listVodStitchDetails(listVodStitchDetailsRequest);
      System.out.println("VOD stitch details:");

      for (VodStitchDetail stitchDetail : response.iterateAll()) {
        System.out.println(stitchDetail.toString());
      }
    }
  }
}

Node.js

Before trying this sample, follow the Node.js setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Node.js API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

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

async function listVodStitchDetails() {
  // Construct request
  const request = {
    parent: stitcherClient.vodSessionPath(projectId, location, sessionId),
  };
  const iterable = await stitcherClient.listVodStitchDetailsAsync(request);
  console.log('VOD stitch details:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listVodStitchDetails();

PHP

Before trying this sample, follow the PHP setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API PHP API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

/**
 * Lists the stitch details for the specified VOD session.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the session
 * @param string $sessionId            The ID of the session
 */
function list_vod_stitch_details(
    string $callingProjectId,
    string $location,
    string $sessionId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->vodSessionName($callingProjectId, $location, $sessionId);
    $request = (new ListVodStitchDetailsRequest())
        ->setParent($formattedName);
    $response = $stitcherClient->listVodStitchDetails($request);

    // Print the stitch details list.
    $stitchDetails = $response->iterateAllElements();
    print('VOD stitch details:' . PHP_EOL);
    foreach ($stitchDetails as $stitchDetail) {
        printf('%s' . PHP_EOL, $stitchDetail->getName());
    }
}

Python

Before trying this sample, follow the Python setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Python API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import argparse

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


def list_vod_stitch_details(
    project_id: str, location: str, session_id: str
) -> pagers.ListVodStitchDetailsPager:
    """Lists the stitch details for the specified VOD session.
    Args:
        project_id: The GCP project ID.
        location: The location of the session.
        session_id: The ID of the VOD session.

    Returns:
        An iterable object containing VOD stitch details resources.
    """

    client = VideoStitcherServiceClient()

    parent = client.vod_session_path(project_id, location, session_id)
    page_result = client.list_vod_stitch_details(parent=parent)
    print("VOD stitch details:")
    for response in page_result:
        print(response)

    return response

Ruby

Before trying this sample, follow the Ruby setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Ruby API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

require "google/cloud/video/stitcher"

##
# List the stitch details for a VOD session
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param session_id [String] The VOD session ID (e.g. "my-vod-session-id")
#
def list_vod_stitch_details project_id:, location:, session_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the parent.
  parent = client.vod_session_path project: project_id, location: location,
                                   vod_session: session_id

  # List all stitch details for the VOD session.
  response = client.list_vod_stitch_details parent: parent

  puts "VOD stitch details:"
  # Print out all VOD stitch details.
  response.each do |vod_stitch_detail|
    puts vod_stitch_detail.name
  end
end

The response returns a list of VodStitchDetail objects. Each VodStitchDetail represents the stitch detail for an ad tag, and each adStitchDetails object represents the stitch detail for a single ad.

This response may include a nextPageToken, which you can use to retrieve additional results:

{
  "vodStitchDetails": [
    ...
  ],
  "nextPageToken": "NEXT_PAGE_TOKEN"
}

You can then send another request, including the value of NEXT_PAGE_TOKEN, to list the additional stitch detail objects. Append the following to the URL in the preceding API call:

?pageToken=NEXT_PAGE_TOKEN

Get ad tag stitch detail

To get the stitch detail for a single ad tag for a VOD session, use the projects.locations.vodSessions.vodStitchDetails.get method.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER: your Google Cloud project number located in the Project number field on the IAM Settings page
  • LOCATION: the location of your session; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SESSION_ID: the session ID for the VOD session
  • VOD_STITCH_DETAILS_ID: the ID for the VOD stitch details

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/vodSessions/SESSION_ID/vodStitchDetails/VOD_STITCH_DETAIL_ID",
  "adStitchDetails": [
    {
      "adBreakId": "AD_BREAK_ID",
      "adId": "AD_ID",
      "adTimeOffset": "AD_TIME_OFFSET",
      "skipReason": "SKIP_REASON",
      "media": "MEDIA_OBJECT"
    }
  ]
}

C#

Before trying this sample, follow the C# setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API C# API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


using Google.Cloud.Video.Stitcher.V1;

public class GetVodStitchDetailSample
{
    public VodStitchDetail GetVodStitchDetail(
        string projectId, string location, string sessionId, string stitchDetailId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        GetVodStitchDetailRequest request = new GetVodStitchDetailRequest
        {
            VodStitchDetailName = VodStitchDetailName.FromProjectLocationVodSessionVodStitchDetail(projectId, location, sessionId, stitchDetailId)
        };

        // Call the API.
        VodStitchDetail vodStitchDetail = client.GetVodStitchDetail(request);

        // Return the result.
        return vodStitchDetail;
    }
}

Go

Before trying this sample, follow the Go setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Go API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// getVodStitchDetail gets the specified stitch detail for a video on demand (VOD) session.
func getVodStitchDetail(w io.Writer, projectID, sessionID, stitchDetailID string) error {
	// projectID := "my-project-id"
	// sessionID := "123-456-789"
	// stitchDetailID := "01234-56789"
	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.GetVodStitchDetailRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/vodSessions/%s/vodStitchDetails/%s", projectID, location, sessionID, stitchDetailID),
	}
	// Gets the stitch detail.
	response, err := client.GetVodStitchDetail(ctx, req)
	if err != nil {
		return fmt.Errorf("client.GetStitchDetail: %w", err)
	}
	b, err := json.MarshalIndent(response, "", " ")
	if err != nil {
		return fmt.Errorf("json.MarshalIndent: %w", err)
	}

	fmt.Fprintf(w, "VOD stitch detail:\n%s", string(b))
	return nil
}

Java

Before trying this sample, follow the Java setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Java API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import com.google.cloud.video.stitcher.v1.GetVodStitchDetailRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodStitchDetail;
import com.google.cloud.video.stitcher.v1.VodStitchDetailName;
import java.io.IOException;

public class GetVodStitchDetail {

  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 sessionId = "my-session-id";
    String stitchDetailId = "my-stitch-id";

    getVodStitchDetail(projectId, location, sessionId, stitchDetailId);
  }

  public static void getVodStitchDetail(
      String projectId, String location, String sessionId, String stitchDetailId)
      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()) {
      GetVodStitchDetailRequest getVodStitchDetailRequest =
          GetVodStitchDetailRequest.newBuilder()
              .setName(
                  VodStitchDetailName.of(projectId, location, sessionId, stitchDetailId).toString())
              .build();

      VodStitchDetail response =
          videoStitcherServiceClient.getVodStitchDetail(getVodStitchDetailRequest);
      System.out.println("VOD stitch detail: " + response.getName());
    }
  }
}

Node.js

Before trying this sample, follow the Node.js setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Node.js API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

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

async function getVodStitchDetail() {
  // Construct request
  const request = {
    name: stitcherClient.vodStitchDetailPath(
      projectId,
      location,
      sessionId,
      stitchDetailId
    ),
  };
  const [stitchDetail] = await stitcherClient.getVodStitchDetail(request);
  console.log(`VOD stitch detail: ${stitchDetail.name}`);
}

getVodStitchDetail();

PHP

Before trying this sample, follow the PHP setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API PHP API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

/**
 * Gets the specified stitch detail for the VOD session.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the session
 * @param string $sessionId            The ID of the session
 * @param string $stitchDetailId       The ID of the stitch detail
 */
function get_vod_stitch_detail(
    string $callingProjectId,
    string $location,
    string $sessionId,
    string $stitchDetailId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->vodStitchDetailName($callingProjectId, $location, $sessionId, $stitchDetailId);
    $request = (new GetVodStitchDetailRequest())
        ->setName($formattedName);
    $stitchDetail = $stitcherClient->getVodStitchDetail($request);

    // Print results
    printf('VOD stitch detail: %s' . PHP_EOL, $stitchDetail->getName());
}

Python

Before trying this sample, follow the Python setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Python API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


import argparse

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


def get_vod_stitch_detail(
    project_id: str, location: str, session_id: str, stitch_detail_id: str
) -> stitcher_v1.types.VodStitchDetail:
    """Gets the specified stitch detail for a VOD session.
    Args:
        project_id: The GCP project ID.
        location: The location of the session.
        session_id: The ID of the VOD session.
        stitch_detail_id: The ID of the stitch details.

    Returns:
        The VOD stitch detail resource.
    """

    client = VideoStitcherServiceClient()

    name = client.vod_stitch_detail_path(
        project_id, location, session_id, stitch_detail_id
    )
    response = client.get_vod_stitch_detail(name=name)
    print(f"VOD stitch detail: {response.name}")
    return response

Ruby

Before trying this sample, follow the Ruby setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Ruby API reference documentation.

To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

require "google/cloud/video/stitcher"

##
# Get the specified stitch detail for a VOD session
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param session_id [String] The VOD session ID (e.g. "my-vod-session-id")
# @param stitch_detail_id [String] The stitch detail ID (e.g. "my-stitch-id")
#
def get_vod_stitch_detail project_id:, location:, session_id:, stitch_detail_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the VOD stitch detail.
  name = client.vod_stitch_detail_path project: project_id, location: location,
                                       vod_session: session_id,
                                       vod_stitch_detail: stitch_detail_id

  # Get the VOD stitch detail.
  stitch_detail = client.get_vod_stitch_detail name: name

  # Print the VOD stitch detail name.
  puts "VOD stitch detail: #{stitch_detail.name}"
end