To enable the Video Stitcher API for your project, please reach out to your Account Representative or contact Sales to learn more.

Create and manage slates

Slates are content that can be served when there are gaps in a livestream ad break that cannot be filled with a dynamically served ad. An ad may be unavailable for a number of reasons, including but not limited to the following:

  • Errors occur while fetching assets from CDNs (content delivery networks)
  • Errors occur during the processing of assets while stitching

Before the Video Stitcher API can insert a slate, the slate video asset must be registered. Registration is needed so that the Video Stitcher API can prepare the slate asset for insertion in the absence of ads.

This document describes how to manage slates. For more details, see the REST documentation.

Register a slate

To register a slate, use the projects.locations.slates.create method.

REST

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

  • PROJECT_NUMBER: your Google Cloud project number; this is located in the Project number field on the IAM Settings page
  • LOCATION: the location in which to create your slate; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: A user-defined identifier for the slate. This ID can only contain lower-case letters, numbers, and hyphens. The first character must be a letter, the last character must be a letter or a number, and the entire ID has a 63 character maximum.
  • SLATE_URL: the public URI for an MP4 video with at least one audio track (sample video)

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Save the request body in a file named request.json. Run the following command in the terminal to create or overwrite this file in the current directory:

cat> request.json << 'EOF' { "uri": "SLATE_URL"
}
EOF

Then execute the following command to send your REST request:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates?slateId=SLATE_ID"

PowerShell (Windows)

Save the request body in a file named request.json. Run the following command in the terminal to create or overwrite this file in the current directory:

@'
{
 "uri": "SLATE_URL"
}
'@ | Out-File -FilePath request.json -Encoding utf8

Then execute the following command to send your REST request:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates?slateId=SLATE_ID" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
 "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
 "metadata": {
 "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
 "createTime": CREATE_TIME,
 "target": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
 "verb": "create",
 "cancelRequested": false,
 "apiVersion": "v1"
 },
 "done": false
}
This command creates a long-running operation (LRO) that you can query to track progress. Copy the returned OPERATION_ID, which is the last part of the name field, to use in the next section.

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.


usingGoogle.Api.Gax.ResourceNames ;
usingGoogle.Cloud.Video.Stitcher.V1 ;
usingGoogle.LongRunning ;
usingSystem.Threading.Tasks;
publicclassCreateSlateSample
{
publicasyncTask<Slate>CreateSlateAsync(
stringprojectId,stringlocation,stringslateId,stringslateUri)
{
// Create the client.
VideoStitcherServiceClient client=VideoStitcherServiceClient .Create ();
CreateSlateRequest request=newCreateSlateRequest
{
ParentAsLocationName=LocationName .FromProjectLocation (projectId,location),
SlateId=slateId,
Slate=newSlate
{
Uri=slateUri
}
};
// Make the request.
Operation<Slate,OperationMetadata>response=awaitclient.CreateSlateAsync (request);
// Poll until the returned long-running operation is complete.
Operation<Slate,OperationMetadata>completedResponse=awaitresponse.PollUntilCompletedAsync();
// Retrieve the operation result.
returncompletedResponse.Result;
}
}

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"
)
// createSlate creates a slate. A slate is displayed when ads are not available.
funccreateSlate(wio.Writer,projectID,slateID,slateURIstring)error{
// projectID := "my-project-id"
// slateID := "my-slate-id"
// slateURI := "https://my-slate-uri/test.mp4"
location:="us-central1"
ctx:=context.Background()
client,err:=stitcher.NewVideoStitcherClient (ctx)
iferr!=nil{
returnfmt.Errorf("stitcher.NewVideoStitcherClient: %w",err)
}
deferclient.Close ()
req:=&stitcherstreampb.CreateSlateRequest{
Parent:fmt.Sprintf("projects/%s/locations/%s",projectID,location),
SlateId:slateID,
Slate:&stitcherstreampb.Slate{
Uri:slateURI,
},
}
// Creates the slate.
op,err:=client.CreateSlate(ctx,req)
iferr!=nil{
returnfmt.Errorf("client.CreateSlate: %w",err)
}
response,err:=op.Wait(ctx)
iferr!=nil{
returnerr
}
fmt.Fprintf(w,"Slate: %v",response.GetName())
returnnil
}

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.


importcom.google.cloud.video.stitcher.v1.CreateSlateRequest ;
importcom.google.cloud.video.stitcher.v1.LocationName ;
importcom.google.cloud.video.stitcher.v1.Slate ;
importcom.google.cloud.video.stitcher.v1.VideoStitcherServiceClient ;
importjava.io.IOException;
importjava.util.concurrent.ExecutionException;
importjava.util.concurrent.TimeUnit;
importjava.util.concurrent.TimeoutException;
publicclass CreateSlate{
privatestaticfinalintTIMEOUT_IN_MINUTES=2;
publicstaticvoidmain(String[]args)throwsException{
// TODO(developer): Replace these variables before running the sample.
StringprojectId="my-project-id";
Stringlocation="us-central1";
StringslateId="my-slate-id";
StringslateUri=
"https://my-slate-uri/test.mp4";// URI of an MP4 video with at least one audio track
createSlate(projectId,location,slateId,slateUri);
}
// Creates a slate. Slates are content that can be served when there are gaps in a livestream
// ad break that cannot be filled with a dynamically served ad. For more information, see
// https://cloud.google.com/video-stitcher/docs/how-to/managing-slates.
publicstaticSlate createSlate(
StringprojectId,Stringlocation,StringslateId,StringslateUri)
throwsIOException,ExecutionException,InterruptedException,TimeoutException{
// 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(VideoStitcherServiceClient videoStitcherServiceClient=
VideoStitcherServiceClient .create()){
CreateSlateRequest createSlateRequest=
CreateSlateRequest .newBuilder()
.setParent(LocationName .of(projectId,location).toString())
.setSlateId (slateId)
.setSlate(Slate .newBuilder().setUri(slateUri).build())
.build();
Slate response=
videoStitcherServiceClient
.createSlateAsync (createSlateRequest)
.get(TIMEOUT_IN_MINUTES,TimeUnit.MINUTES);
System.out.println("Created new slate: "+response.getName ());
returnresponse;
}
}
}

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';
// slateId = 'my-slate';
// slateUri = 'https://my-slate-uri/test.mp4';
// Imports the Video Stitcher library
const{VideoStitcherServiceClient}=
require('@google-cloud/video-stitcher').v1;
// Instantiates a client
conststitcherClient=newVideoStitcherServiceClient ();
asyncfunctioncreateSlate(){
// Construct request
constrequest={
parent:stitcherClient.locationPath (projectId,location),
slate:{
uri:slateUri,
},
slateId:slateId,
};
const[operation]=awaitstitcherClient.createSlate(request);
const[response]=awaitoperation.promise();
console.log(`response.name: ${response.name}`);
}
createSlate().catch(err=>{
console.error(err.message);
process.exitCode=1;
});

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\CreateSlateRequest;
use Google\Cloud\Video\Stitcher\V1\Slate;
/**
 * Creates a slate. A slate is displayed when ads are not available.
 *
 * @param string $callingProjectId The project ID to run the API call under
 * @param string $location The location of the slate
 * @param string $slateId The name of the slate to be created
 * @param string $slateUri The public URI for an MP4 video with at least one audio track
 */
function create_slate(
 string $callingProjectId,
 string $location,
 string $slateId,
 string $slateUri
): void {
 // Instantiate a client.
 $stitcherClient = new VideoStitcherServiceClient();
 $parent = $stitcherClient->locationName($callingProjectId, $location);
 $slate = new Slate();
 $slate->setUri($slateUri);
 // Run slate creation request
 $request = (new CreateSlateRequest())
 ->setParent($parent)
 ->setSlateId($slateId)
 ->setSlate($slate);
 $operationResponse = $stitcherClient->createSlate($request);
 $operationResponse->pollUntilComplete();
 if ($operationResponse->operationSucceeded()) {
 $result = $operationResponse->getResult();
 // Print results
 printf('Slate: %s' . PHP_EOL, $result->getName());
 } else {
 $error = $operationResponse->getError();
 // handleError($error)
 }
}

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.


importargparse
fromgoogle.cloud.videoimport stitcher_v1
fromgoogle.cloud.video.stitcher_v1.services.video_stitcher_serviceimport (
 VideoStitcherServiceClient,
)
defcreate_slate(
 project_id: str, location: str, slate_id: str, slate_uri: str
) -> stitcher_v1.types.Slate:
"""Creates a slate.
 Args:
 project_id: The GCP project ID.
 location: The location in which to create the slate.
 slate_id: The user-defined slate ID.
 slate_uri: Uri of the video slate; must be an MP4 video with at least one audio track.
 Returns:
 The slate resource.
 """
 client = VideoStitcherServiceClient()
 parent = f"projects/{project_id}/locations/{location}"
 slate = stitcher_v1.types.Slate(
 uri=slate_uri,
 )
 operation = client.create_slate(parent=parent, slate_id=slate_id, slate=slate)
 response = operation.result()
 print(f"Slate: {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"
##
# Create a slate
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param slate_id [String] Your slate name (e.g. `my-slate`)
# @param slate_uri [String] The URI of an MP4 video with at least one audio
# track (e.g. `https://my-slate-uri/test.mp4`)
#
defcreate_slateproject_id:,location:,slate_id:,slate_uri:
# Create a Video Stitcher client.
client=Google::Cloud::Video::Stitcher.video_stitcher_service
# Build the resource name of the parent.
parent=client.location_pathproject:project_id,location:location
# Set the slate fields.
new_slate={
uri:slate_uri
}
operation=client.create_slateparent:parent,slate_id:slate_id,
slate:new_slate
# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
operation.wait_until_done!
# Print the slate name.
puts"Slate: #{operation.response.name}"
end

Check for the result

To check if the slate has been created, use the projects.locations.operations.get method. If the response contains "done: false", repeat the command until the response contains "done: true".

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

  • PROJECT_NUMBER: your Google Cloud project number; this is located in the Project number field on the IAM Settings page
  • LOCATION: the location of the data; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • OPERATION_ID: the identifier for the operation

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID"

PowerShell (Windows)

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
 "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
 "metadata": {
 "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
 "createTime": CREATE_TIME,
 "endTime": END_TIME,
 "target": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
 "verb": "create",
 "cancelRequested": false,
 "apiVersion": "v1"
 },
 "done": true,
 "response": {
 "@type": "type.googleapis.com/google.cloud.video.stitcher.v1.Slate",
 "name": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
 "uri": "SLATE_URL"
 }
}

Get a slate

To get the details for a specific slate, use the projects.locations.slates.get method.

REST

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

  • PROJECT_NUMBER: your Google Cloud project number; this is located in the Project number field on the IAM Settings page
  • LOCATION: the location where your slate is located; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: a user-defined identifier for the slate

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID"

PowerShell (Windows)

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
 "name": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
 "uri": "SLATE_URL"
}

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.


usingGoogle.Cloud.Video.Stitcher.V1 ;
publicclassGetSlateSample
{
publicSlateGetSlate(
stringprojectId,stringlocation,stringslateId)
{
// Create the client.
VideoStitcherServiceClient client=VideoStitcherServiceClient .Create ();
GetSlateRequest request=newGetSlateRequest
{
SlateName=SlateName .FromProjectLocationSlate (projectId,location,slateId)
};
// Call the API.
Slate response=client.GetSlate (request);
// Return the result.
returnresponse;
}
}

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"
)
// getSlate gets a previously-created slate.
funcgetSlate(wio.Writer,projectID,slateIDstring)error{
// projectID := "my-project-id"
// slateID := "my-slate-id"
location:="us-central1"
ctx:=context.Background()
client,err:=stitcher.NewVideoStitcherClient (ctx)
iferr!=nil{
returnfmt.Errorf("stitcher.NewVideoStitcherClient: %w",err)
}
deferclient.Close ()
req:=&stitcherstreampb.GetSlateRequest{
Name:fmt.Sprintf("projects/%s/locations/%s/slates/%s",projectID,location,slateID),
}
response,err:=client.GetSlate(ctx,req)
iferr!=nil{
returnfmt.Errorf("client.GetSlate: %w",err)
}
b,err:=json.MarshalIndent(response,""," ")
iferr!=nil{
returnfmt.Errorf("json.MarshalIndent: %w",err)
}
fmt.Fprintf(w,"Slate:\n%s",string(b))
returnnil
}

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.


importcom.google.cloud.video.stitcher.v1.GetSlateRequest ;
importcom.google.cloud.video.stitcher.v1.Slate ;
importcom.google.cloud.video.stitcher.v1.SlateName ;
importcom.google.cloud.video.stitcher.v1.VideoStitcherServiceClient ;
importjava.io.IOException;
publicclass GetSlate{
publicstaticvoidmain(String[]args)throwsException{
// TODO(developer): Replace these variables before running the sample.
StringprojectId="my-project-id";
Stringlocation="us-central1";
StringslateId="my-slate-id";
getSlate(projectId,location,slateId);
}
// Gets a slate.
publicstaticSlate getSlate(StringprojectId,Stringlocation,StringslateId)
throwsIOException{
// 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(VideoStitcherServiceClient videoStitcherServiceClient=
VideoStitcherServiceClient .create()){
GetSlateRequest getSlateRequest=
GetSlateRequest .newBuilder()
.setName(SlateName .of(projectId,location,slateId).toString())
.build();
Slate response=videoStitcherServiceClient.getSlate(getSlateRequest);
System.out.println("Slate: "+response.getName ());
returnresponse;
}
}
}

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';
// slateId = 'my-slate';
// Imports the Video Stitcher library
const{VideoStitcherServiceClient}=
require('@google-cloud/video-stitcher').v1;
// Instantiates a client
conststitcherClient=newVideoStitcherServiceClient ();
asyncfunctiongetSlate(){
// Construct request
constrequest={
name:stitcherClient.slatePath (projectId,location,slateId),
};
const[slate]=awaitstitcherClient.getSlate(request);
console.log(`Slate: ${slate.name}`);
}
getSlate().catch(err=>{
console.error(err.message);
process.exitCode=1;
});

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\GetSlateRequest;
/**
 * Gets a slate.
 *
 * @param string $callingProjectId The project ID to run the API call under
 * @param string $location The location of the slate
 * @param string $slateId The ID of the slate
 */
function get_slate(
 string $callingProjectId,
 string $location,
 string $slateId
): void {
 // Instantiate a client.
 $stitcherClient = new VideoStitcherServiceClient();
 $formattedName = $stitcherClient->slateName($callingProjectId, $location, $slateId);
 $request = (new GetSlateRequest())
 ->setName($formattedName);
 $slate = $stitcherClient->getSlate($request);
 // Print results
 printf('Slate: %s' . PHP_EOL, $slate->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.


importargparse
fromgoogle.cloud.videoimport stitcher_v1
fromgoogle.cloud.video.stitcher_v1.services.video_stitcher_serviceimport (
 VideoStitcherServiceClient,
)
defget_slate(project_id: str, location: str, slate_id: str) -> stitcher_v1.types.Slate:
"""Gets a slate.
 Args:
 project_id: The GCP project ID.
 location: The location of the slate.
 slate_id: The user-defined slate ID.
 Returns:
 The slate resource.
 """
 client = VideoStitcherServiceClient()
 name = f"projects/{project_id}/locations/{location}/slates/{slate_id}"
 response = client.get_slate(name=name)
 print(f"Slate: {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 a slate
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param slate_id [String] Your slate name (e.g. `my-slate`)
#
defget_slateproject_id:,location:,slate_id:
# Create a Video Stitcher client.
client=Google::Cloud::Video::Stitcher.video_stitcher_service
# Build the resource name of the slate.
name=client.slate_pathproject:project_id,location:location,
slate:slate_id
# Get the slate.
slate=client.get_slatename:name
# Print the slate name.
puts"Slate: #{slate.name}"
end

Update a slate

To update a specific slate, use the projects.locations.slates.patch method.

REST

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

  • PROJECT_NUMBER: your Google Cloud project number; this is located in the Project number field on the IAM Settings page
  • LOCATION: the location to create your slate; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: a user-defined identifier for the slate
  • SLATE_URL: this URI must return an MP4 video with at least one audio track

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Save the request body in a file named request.json. Run the following command in the terminal to create or overwrite this file in the current directory:

cat> request.json << 'EOF' { "uri": "SLATE_URL"
}
EOF

Then execute the following command to send your REST request:

curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID?updateMask=uri"

PowerShell (Windows)

Save the request body in a file named request.json. Run the following command in the terminal to create or overwrite this file in the current directory:

@'
{
 "uri": "SLATE_URL"
}
'@ | Out-File -FilePath request.json -Encoding utf8

Then execute the following command to send your REST request:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID?updateMask=uri" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
 "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
 "metadata": {
 "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
 "createTime": CREATE_TIME,
 "target": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
 "verb": "update",
 "cancelRequested": false,
 "apiVersion": "v1"
 },
 "done": false
}
This command creates a long-running operation (LRO) that you can query to track progress. For more information, see Check for the result.

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.


usingGoogle.Cloud.Video.Stitcher.V1 ;
usingGoogle.LongRunning ;
usingGoogle.Protobuf.WellKnownTypes ;
usingSystem.Threading.Tasks;
publicclassUpdateSlateSample
{
publicasyncTask<Slate>UpdateSlateAsync(
stringprojectId,stringlocation,stringslateId,stringslateUri)
{
// Create the client.
VideoStitcherServiceClient client=VideoStitcherServiceClient .Create ();
UpdateSlateRequest request=newUpdateSlateRequest
{
Slate=newSlate
{
SlateName=SlateName .FromProjectLocationSlate (projectId,location,slateId),
Uri=slateUri
},
UpdateMask=newFieldMask {Paths={"uri"}}
};
// Make the request.
Operation<Slate,OperationMetadata>response=awaitclient.UpdateSlateAsync (request);
// Poll until the returned long-running operation is complete.
Operation<Slate,OperationMetadata>completedResponse=awaitresponse.PollUntilCompletedAsync();
// Retrieve the operation result.
returncompletedResponse.Result;
}
}

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/protobuf/types/known/fieldmaskpb"
)
// updateSlate updates an existing slate. This sample updates the uri for an
// existing slate.
funcupdateSlate(wio.Writer,projectID,slateID,slateURIstring)error{
// projectID := "my-project-id"
// slateID := "my-slate-id"
// slateURI := "https://my-updated-slate-uri/test.mp4"
location:="us-central1"
ctx:=context.Background()
client,err:=stitcher.NewVideoStitcherClient (ctx)
iferr!=nil{
returnfmt.Errorf("stitcher.NewVideoStitcherClient: %w",err)
}
deferclient.Close ()
req:=&stitcherstreampb.UpdateSlateRequest{
Slate:&stitcherstreampb.Slate{
Name:fmt.Sprintf("projects/%s/locations/%s/slates/%s",projectID,location,slateID),
Uri:slateURI,
},
UpdateMask:&fieldmaskpb.FieldMask{
Paths:[]string{
"uri",
},
},
}
// Updates the slate.
op,err:=client.UpdateSlate(ctx,req)
iferr!=nil{
returnfmt.Errorf("client.UpdateSlate: %w",err)
}
response,err:=op.Wait(ctx)
iferr!=nil{
returnerr
}
fmt.Fprintf(w,"Updated slate: %+v",response)
returnnil
}

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.


importcom.google.cloud.video.stitcher.v1.Slate ;
importcom.google.cloud.video.stitcher.v1.SlateName ;
importcom.google.cloud.video.stitcher.v1.UpdateSlateRequest ;
importcom.google.cloud.video.stitcher.v1.VideoStitcherServiceClient ;
importcom.google.protobuf.FieldMask ;
importjava.io.IOException;
importjava.util.concurrent.ExecutionException;
importjava.util.concurrent.TimeUnit;
importjava.util.concurrent.TimeoutException;
publicclass UpdateSlate{
privatestaticfinalintTIMEOUT_IN_MINUTES=2;
publicstaticvoidmain(String[]args)throwsException{
// TODO(developer): Replace these variables before running the sample.
StringprojectId="my-project-id";
Stringlocation="us-central1";
StringslateId="my-slate-id";
StringslateUri=
"https://my-slate-uri/test.mp4";// URI of an MP4 video with at least one audio track
updateSlate(projectId,location,slateId,slateUri);
}
// updateSlate updates the slate URI for an existing slate.
publicstaticSlate updateSlate(
StringprojectId,Stringlocation,StringslateId,StringslateUri)
throwsIOException,ExecutionException,InterruptedException,TimeoutException{
// 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(VideoStitcherServiceClient videoStitcherServiceClient=
VideoStitcherServiceClient .create()){
UpdateSlateRequest updateSlateRequest=
UpdateSlateRequest .newBuilder()
.setSlate(
Slate .newBuilder()
.setName(SlateName .of(projectId,location,slateId).toString())
.setUri(slateUri)
.build())
// Set the update mask to the uri field in the existing slate. You must set the mask
// to the field you want to update.
.setUpdateMask(FieldMask .newBuilder().addPaths ("uri").build())
.build();
Slate response=
videoStitcherServiceClient
.updateSlateAsync (updateSlateRequest)
.get(TIMEOUT_IN_MINUTES,TimeUnit.MINUTES);
System.out.println("Updated slate: "+response.getName ());
returnresponse;
}
}
}

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';
// slateId = 'my-slate';
// slateUri = 'https://my-slate-uri/test.mp4';
// Imports the Video Stitcher library
const{VideoStitcherServiceClient}=
require('@google-cloud/video-stitcher').v1;
// Instantiates a client
conststitcherClient=newVideoStitcherServiceClient ();
asyncfunctionupdateSlate(){
// Construct request
constrequest={
slate:{
name:stitcherClient.slatePath (projectId,location,slateId),
uri:slateUri,
},
updateMask:{
paths:['uri'],
},
};
const[operation]=awaitstitcherClient.updateSlate(request);
const[response]=awaitoperation.promise();
console.log(`Updated slate: ${response.name}`);
console.log(`Updated uri: ${response.uri}`);
}
updateSlate().catch(err=>{
console.error(err.message);
process.exitCode=1;
});

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\Slate;
use Google\Cloud\Video\Stitcher\V1\UpdateSlateRequest;
use Google\Protobuf\FieldMask;
/**
 * Updates a slate's uri field.
 *
 * @param string $callingProjectId The project ID to run the API call under
 * @param string $location The location of the slate
 * @param string $slateId The name of the slate to be created
 * @param string $slateUri The public URI for an MP4 video with at least one audio track
 */
function update_slate(
 string $callingProjectId,
 string $location,
 string $slateId,
 string $slateUri
): void {
 // Instantiate a client.
 $stitcherClient = new VideoStitcherServiceClient();
 $formattedName = $stitcherClient->slateName($callingProjectId, $location, $slateId);
 $slate = new Slate();
 $slate->setName($formattedName);
 $slate->setUri($slateUri);
 $updateMask = new FieldMask([
 'paths' => ['uri']
 ]);
 // Run slate update request
 $request = (new UpdateSlateRequest())
 ->setSlate($slate)
 ->setUpdateMask($updateMask);
 $operationResponse = $stitcherClient->updateSlate($request);
 $operationResponse->pollUntilComplete();
 if ($operationResponse->operationSucceeded()) {
 $result = $operationResponse->getResult();
 // Print results
 printf('Updated slate: %s' . PHP_EOL, $result->getName());
 } else {
 $error = $operationResponse->getError();
 // handleError($error)
 }
}

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.


importargparse
fromgoogle.cloud.videoimport stitcher_v1
fromgoogle.cloud.video.stitcher_v1.services.video_stitcher_serviceimport (
 VideoStitcherServiceClient,
)
fromgoogle.protobufimport field_mask_pb2 as field_mask
defupdate_slate(
 project_id: str, location: str, slate_id: str, slate_uri: str
) -> stitcher_v1.types.Slate:
"""Updates a slate.
 Args:
 project_id: The GCP project ID.
 location: The location of the slate.
 slate_id: The existing slate's ID.
 slate_uri: Updated uri of the video slate; must be an MP4 video with at least one audio track.
 Returns:
 The slate resource.
 """
 client = VideoStitcherServiceClient()
 name = f"projects/{project_id}/locations/{location}/slates/{slate_id}"
 slate = stitcher_v1.types.Slate(
 name=name,
 uri=slate_uri,
 )
 update_mask = field_mask.FieldMask(paths=["uri"])
 operation = client.update_slate(slate=slate, update_mask=update_mask)
 response = operation.result()
 print(f"Updated slate: {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"
##
# Update a slate
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param slate_id [String] Your slate name (e.g. `my-slate`)
# @param slate_uri [String] The URI of an MP4 video with at least one audio
# track (e.g. `https://my-slate-uri/test.mp4`)
#
defupdate_slateproject_id:,location:,slate_id:,slate_uri:
# Create a Video Stitcher client.
client=Google::Cloud::Video::Stitcher.video_stitcher_service
# Build the resource name of the slate.
name=client.slate_pathproject:project_id,location:location,
slate:slate_id
# Set the update mask.
update_mask={paths:["uri"]}
# Set the slate fields.
update_slate={
name:name,
uri:slate_uri
}
operation=client.update_slateslate:update_slate,update_mask:update_mask
# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
operation.wait_until_done!
# Print the slate name.
puts"Updated slate: #{operation.response.name}"
puts"Updated uri: #{operation.response.uri}"
end

List all registered slates

To list all of the slates registered for a given location in a project, use the projects.locations.slates.list method.

REST

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

  • PROJECT_NUMBER: your Google Cloud project number; this is located in the Project number field on the IAM Settings page
  • LOCATION: the location where your slates are located; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Execute the following command:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates"

PowerShell (Windows)

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
 "slates": [
 {
 "name": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
 "uri": "SLATE_URL"
 },
 {
 "name": "projects/PROJECT_NUMBER/locations/LOCATION/slates/my-other-slate-id",
 "uri": "my-other-slate-url"
 }
 ]
}

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.


usingGoogle.Api.Gax ;
usingGoogle.Api.Gax.ResourceNames ;
usingGoogle.Cloud.Video.Stitcher.V1 ;
usingSystem;
publicclassListSlatesSample
{
publicPagedEnumerable<ListSlatesResponse,Slate>ListSlates(
stringprojectId,stringregionId)
{
// Create the client.
VideoStitcherServiceClient client=VideoStitcherServiceClient .Create ();
ListSlatesRequest request=newListSlatesRequest
{
ParentAsLocationName=LocationName .FromProjectLocation (projectId,regionId)
};
// Make the request.
PagedEnumerable<ListSlatesResponse,Slate>response=client.ListSlates (request);
foreach(Slate slateinresponse)
{
Console.WriteLine($"{slate.Name}");
}
// Return the result.
returnresponse;
}
}

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"
)
// listSlates lists all slates for a given location.
funclistSlates(wio.Writer,projectIDstring)error{
// projectID := "my-project-id"
location:="us-central1"
ctx:=context.Background()
client,err:=stitcher.NewVideoStitcherClient (ctx)
iferr!=nil{
returnfmt.Errorf("stitcher.NewVideoStitcherClient: %w",err)
}
deferclient.Close ()
req:=&stitcherstreampb.ListSlatesRequest{
Parent:fmt.Sprintf("projects/%s/locations/%s",projectID,location),
}
it:=client.ListSlates(ctx,req)
fmt.Fprintln(w,"Slates:")
for{
response,err:=it.Next()
iferr==iterator.Done{
break
}
iferr!=nil{
returnfmt.Errorf("it.Next(): %w",err)
}
fmt.Fprintln(w,response.GetName())
}
returnnil
}

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.


importcom.google.cloud.video.stitcher.v1.ListSlatesRequest ;
importcom.google.cloud.video.stitcher.v1.LocationName ;
importcom.google.cloud.video.stitcher.v1.Slate ;
importcom.google.cloud.video.stitcher.v1.VideoStitcherServiceClient ;
importcom.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListSlatesPagedResponse ;
importjava.io.IOException;
publicclass ListSlates{
publicstaticvoidmain(String[]args)throwsException{
// TODO(developer): Replace these variables before running the sample.
StringprojectId="my-project-id";
Stringlocation="us-central1";
listSlates(projectId,location);
}
// Lists the slates for a given project and location.
publicstaticListSlatesPagedResponse listSlates(StringprojectId,Stringlocation)
throwsIOException{
// 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(VideoStitcherServiceClient videoStitcherServiceClient=
VideoStitcherServiceClient .create()){
ListSlatesRequest listSlatesRequest=
ListSlatesRequest .newBuilder()
.setParent(LocationName .of(projectId,location).toString())
.build();
VideoStitcherServiceClient .ListSlatesPagedResponse response=
videoStitcherServiceClient.listSlates(listSlatesRequest);
System.out.println("Slates:");
for(Slate slate:response.iterateAll()){
System.out.println(slate.getName());
}
returnresponse;
}
}
}

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';
// Imports the Video Stitcher library
const{VideoStitcherServiceClient}=
require('@google-cloud/video-stitcher').v1;
// Instantiates a client
conststitcherClient=newVideoStitcherServiceClient ();
asyncfunctionlistSlates(){
constiterable=awaitstitcherClient.listSlatesAsync ({
parent:stitcherClient.locationPath (projectId,location),
});
console.info('Slates:');
forawait(constresponseofiterable){
console.log(response.name);
}
}
listSlates().catch(err=>{
console.error(err.message);
process.exitCode=1;
});

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\ListSlatesRequest;
/**
 * Lists all slates for a location.
 *
 * @param string $callingProjectId The project ID to run the API call under
 * @param string $location The location of the slates
 */
function list_slates(
 string $callingProjectId,
 string $location
): void {
 // Instantiate a client.
 $stitcherClient = new VideoStitcherServiceClient();
 $parent = $stitcherClient->locationName($callingProjectId, $location);
 $request = (new ListSlatesRequest())
 ->setParent($parent);
 $response = $stitcherClient->listSlates($request);
 // Print the slate list.
 $slates = $response->iterateAllElements();
 print('Slates:' . PHP_EOL);
 foreach ($slates as $slate) {
 printf('%s' . PHP_EOL, $slate->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.


importargparse
fromgoogle.cloud.video.stitcher_v1.services.video_stitcher_serviceimport (
 pagers,
 VideoStitcherServiceClient,
)
deflist_slates(project_id: str, location: str) -> pagers.ListSlatesPager:
"""Lists all slates in a location.
 Args:
 project_id: The GCP project ID.
 location: The location of the slates.
 Returns:
 An iterable object containing slate resources.
 """
 client = VideoStitcherServiceClient()
 parent = f"projects/{project_id}/locations/{location}"
 response = client.list_slates(parent=parent)
 print("Slates:")
 for slate in response.slates:
 print({slate.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"
##
# List slates for a given location
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
#
deflist_slatesproject_id:,location:
# Create a Video Stitcher client.
client=Google::Cloud::Video::Stitcher.video_stitcher_service
# Build the resource name of the parent.
parent=client.location_pathproject:project_id,location:location
response=client.list_slatesparent:parent
puts"Slates:"
# Print out all slates.
response.eachdo|slate|
putsslate.name
end
end

Additional results

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

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

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

?pageToken=NEXT_PAGE_TOKEN

See the relevant client library for more information on using this token.

Delete a slate

If a registered slate is no longer needed, delete it using the projects.locations.slates.delete method.

REST

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

  • PROJECT_NUMBER: your Google Cloud project number; this is located in the Project number field on the IAM Settings page
  • LOCATION: the location where your slate is located; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SLATE_ID: a user-defined identifier for the slate

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Execute the following command:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID"

PowerShell (Windows)

Execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{
 "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
 "metadata": {
 "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
 "createTime": CREATE_TIME,
 "target": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
 "verb": "delete",
 "cancelRequested": false,
 "apiVersion": "v1"
 },
 "done": false
}
This command creates a long-running operation (LRO) that you can query to track progress. For more information, see Check for the result.

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.


usingGoogle.Cloud.Video.Stitcher.V1 ;
usingGoogle.LongRunning ;
usingGoogle.Protobuf.WellKnownTypes ;
usingSystem.Threading.Tasks;
publicclassDeleteSlateSample
{
publicasyncTaskDeleteSlateAsync(
stringprojectId,stringlocation,stringslateId)
{
// Create the client.
VideoStitcherServiceClient client=VideoStitcherServiceClient .Create ();
DeleteSlateRequest request=newDeleteSlateRequest
{
SlateName=SlateName .FromProjectLocationSlate (projectId,location,slateId)
};
// Make the request.
Operation<Empty,OperationMetadata>response=awaitclient.DeleteSlateAsync (request);
// Poll until the returned long-running operation is complete.
awaitresponse.PollUntilCompletedAsync();
}
}

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"
)
// deleteSlate deletes a previously-created slate.
funcdeleteSlate(wio.Writer,projectID,slateIDstring)error{
// projectID := "my-project-id"
// slateID := "my-slate-id"
location:="us-central1"
ctx:=context.Background()
client,err:=stitcher.NewVideoStitcherClient (ctx)
iferr!=nil{
returnfmt.Errorf("stitcher.NewVideoStitcherClient: %w",err)
}
deferclient.Close ()
name:=fmt.Sprintf("projects/%s/locations/%s/slates/%s",projectID,location,slateID)
req:=&stitcherstreampb.DeleteSlateRequest{
Name:name,
}
// Deletes the slate.
op,err:=client.DeleteSlate(ctx,req)
iferr!=nil{
returnfmt.Errorf("client.DeleteSlate: %w",err)
}
err=op.Wait(ctx)
iferr!=nil{
returnerr
}
fmt.Fprintf(w,"Deleted slate")
returnnil
}

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.


importcom.google.cloud.video.stitcher.v1.DeleteSlateRequest ;
importcom.google.cloud.video.stitcher.v1.SlateName ;
importcom.google.cloud.video.stitcher.v1.VideoStitcherServiceClient ;
importjava.io.IOException;
importjava.util.concurrent.ExecutionException;
importjava.util.concurrent.TimeUnit;
importjava.util.concurrent.TimeoutException;
publicclass DeleteSlate{
privatestaticfinalintTIMEOUT_IN_MINUTES=2;
publicstaticvoidmain(String[]args)throwsException{
// TODO(developer): Replace these variables before running the sample.
StringprojectId="my-project-id";
Stringlocation="us-central1";
StringslateId="my-slate-id";
deleteSlate(projectId,location,slateId);
}
// Deletes a slate.
publicstaticvoiddeleteSlate(StringprojectId,Stringlocation,StringslateId)
throwsIOException,ExecutionException,InterruptedException,TimeoutException{
// 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(VideoStitcherServiceClient videoStitcherServiceClient=
VideoStitcherServiceClient .create()){
DeleteSlateRequest deleteSlateRequest=
DeleteSlateRequest .newBuilder()
.setName(SlateName .of(projectId,location,slateId).toString())
.build();
videoStitcherServiceClient
.deleteSlateAsync (deleteSlateRequest)
.get(TIMEOUT_IN_MINUTES,TimeUnit.MINUTES);
System.out.println("Deleted slate");
}
}
}

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';
// slateId = 'my-slate';
// Imports the Video Stitcher library
const{VideoStitcherServiceClient}=
require('@google-cloud/video-stitcher').v1;
// Instantiates a client
conststitcherClient=newVideoStitcherServiceClient ();
asyncfunctiondeleteSlate(){
// Construct request
constrequest={
name:stitcherClient.slatePath (projectId,location,slateId),
};
const[operation]=awaitstitcherClient.deleteSlate(request);
awaitoperation.promise();
console.log('Deleted slate');
}
deleteSlate().catch(err=>{
console.error(err.message);
process.exitCode=1;
});

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\DeleteSlateRequest;
/**
 * Deletes a slate.
 *
 * @param string $callingProjectId The project ID to run the API call under
 * @param string $location The location of the slate
 * @param string $slateId The ID of the slate
 */
function delete_slate(
 string $callingProjectId,
 string $location,
 string $slateId
): void {
 // Instantiate a client.
 $stitcherClient = new VideoStitcherServiceClient();
 $formattedName = $stitcherClient->slateName($callingProjectId, $location, $slateId);
 $request = (new DeleteSlateRequest())
 ->setName($formattedName);
 $operationResponse = $stitcherClient->deleteSlate($request);
 $operationResponse->pollUntilComplete();
 if ($operationResponse->operationSucceeded()) {
 // Print status
 printf('Deleted slate %s' . PHP_EOL, $slateId);
 } else {
 $error = $operationResponse->getError();
 // handleError($error)
 }
}

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.


importargparse
fromgoogle.cloud.video.stitcher_v1.services.video_stitcher_serviceimport (
 VideoStitcherServiceClient,
)
fromgoogle.protobufimport empty_pb2 as empty
defdelete_slate(project_id: str, location: str, slate_id: str) -> empty.Empty:
"""Deletes a slate.
 Args:
 project_id: The GCP project ID.
 location: The location of the slate.
 slate_id: The user-defined slate ID."""
 client = VideoStitcherServiceClient()
 name = f"projects/{project_id}/locations/{location}/slates/{slate_id}"
 operation = client.delete_slate(name=name)
 response = operation.result()
 print("Deleted slate")
 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"
##
# Delete a slate
#
# @param project_id [String] Your Google Cloud project (e.g. `my-project`)
# @param location [String] The location (e.g. `us-central1`)
# @param slate_id [String] Your slate name (e.g. `my-slate`)
#
defdelete_slateproject_id:,location:,slate_id:
# Create a Video Stitcher client.
client=Google::Cloud::Video::Stitcher.video_stitcher_service
# Build the resource name of the slate.
name=client.slate_pathproject:project_id,location:location,
slate:slate_id
# Delete the slate.
operation=client.delete_slatename:name
# The returned object is of type Gapic::Operation. You can use this
# object to check the status of an operation, cancel it, or wait
# for results. Here is how to block until completion:
operation.wait_until_done!
# Print a success message.
puts"Deleted slate"
end

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月30日 UTC.