Skip to content

Commit 8d62377

Browse files
authored
chore: upgrade videostitcher samples to new GAPIC (GoogleCloudPlatform#1871)
1 parent ff03a0d commit 8d62377

26 files changed

+145
-54
lines changed

media/videostitcher/src/create_cdn_key.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_create_cdn_key]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
2928
use Google\Cloud\Video\Stitcher\V1\CdnKey;
29+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
30+
use Google\Cloud\Video\Stitcher\V1\CreateCdnKeyRequest;
3031
use Google\Cloud\Video\Stitcher\V1\GoogleCdnKey;
3132
use Google\Cloud\Video\Stitcher\V1\MediaCdnKey;
3233

@@ -75,7 +76,11 @@ function create_cdn_key(
7576
$cloudCdn->setPrivateKey($privateKey);
7677

7778
// Run CDN key creation request
78-
$operationResponse = $stitcherClient->createCdnKey($parent, $cdnKey, $cdnKeyId);
79+
$request = (new CreateCdnKeyRequest())
80+
->setParent($parent)
81+
->setCdnKey($cdnKey)
82+
->setCdnKeyId($cdnKeyId);
83+
$operationResponse = $stitcherClient->createCdnKey($request);
7984
$operationResponse->pollUntilComplete();
8085
if ($operationResponse->operationSucceeded()) {
8186
$result = $operationResponse->getResult();

media/videostitcher/src/create_cdn_key_akamai.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_create_cdn_key_akamai]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
29-
use Google\Cloud\Video\Stitcher\V1\CdnKey;
3028
use Google\Cloud\Video\Stitcher\V1\AkamaiCdnKey;
29+
use Google\Cloud\Video\Stitcher\V1\CdnKey;
30+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
31+
use Google\Cloud\Video\Stitcher\V1\CreateCdnKeyRequest;
3132

3233
/**
3334
* Creates an Akamai CDN key.
@@ -57,7 +58,11 @@ function create_cdn_key_akamai(
5758
$cdnKey->setAkamaiCdnKey($cloudCdn);
5859

5960
// Run CDN key creation request
60-
$operationResponse = $stitcherClient->createCdnKey($parent, $cdnKey, $cdnKeyId);
61+
$request = (new CreateCdnKeyRequest())
62+
->setParent($parent)
63+
->setCdnKey($cdnKey)
64+
->setCdnKeyId($cdnKeyId);
65+
$operationResponse = $stitcherClient->createCdnKey($request);
6166
$operationResponse->pollUntilComplete();
6267
if ($operationResponse->operationSucceeded()) {
6368
$result = $operationResponse->getResult();

media/videostitcher/src/create_live_config.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_create_live_config]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
2928
use Google\Cloud\Video\Stitcher\V1\AdTracking;
29+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
30+
use Google\Cloud\Video\Stitcher\V1\CreateLiveConfigRequest;
3031
use Google\Cloud\Video\Stitcher\V1\LiveConfig;
3132

3233
/**
@@ -66,7 +67,11 @@ function create_live_config(
6667
->setDefaultSlate($defaultSlate);
6768

6869
// Run live config creation request
69-
$operationResponse = $stitcherClient->createLiveConfig($parent, $liveConfigId, $liveConfig);
70+
$request = (new CreateLiveConfigRequest())
71+
->setParent($parent)
72+
->setLiveConfigId($liveConfigId)
73+
->setLiveConfig($liveConfig);
74+
$operationResponse = $stitcherClient->createLiveConfig($request);
7075
$operationResponse->pollUntilComplete();
7176
if ($operationResponse->operationSucceeded()) {
7277
$result = $operationResponse->getResult();

media/videostitcher/src/create_live_session.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_create_live_session]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
28+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
29+
use Google\Cloud\Video\Stitcher\V1\CreateLiveSessionRequest;
2930
use Google\Cloud\Video\Stitcher\V1\LiveSession;
3031

3132
/**
@@ -51,7 +52,10 @@ function create_live_session(
5152
$liveSession->setLiveConfig($liveConfig);
5253

5354
// Run live session creation request
54-
$response = $stitcherClient->createLiveSession($parent, $liveSession);
55+
$request = (new CreateLiveSessionRequest())
56+
->setParent($parent)
57+
->setLiveSession($liveSession);
58+
$response = $stitcherClient->createLiveSession($request);
5559

5660
// Print results
5761
printf('Live session: %s' . PHP_EOL, $response->getName());

media/videostitcher/src/create_slate.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_create_slate]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
28+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
29+
use Google\Cloud\Video\Stitcher\V1\CreateSlateRequest;
2930
use Google\Cloud\Video\Stitcher\V1\Slate;
3031

3132
/**
@@ -50,7 +51,11 @@ function create_slate(
5051
$slate->setUri($slateUri);
5152

5253
// Run slate creation request
53-
$operationResponse = $stitcherClient->createSlate($parent, $slateId, $slate);
54+
$request = (new CreateSlateRequest())
55+
->setParent($parent)
56+
->setSlateId($slateId)
57+
->setSlate($slate);
58+
$operationResponse = $stitcherClient->createSlate($request);
5459
$operationResponse->pollUntilComplete();
5560
if ($operationResponse->operationSucceeded()) {
5661
$result = $operationResponse->getResult();

media/videostitcher/src/create_vod_session.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_create_vod_session]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
2928
use Google\Cloud\Video\Stitcher\V1\AdTracking;
29+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
30+
use Google\Cloud\Video\Stitcher\V1\CreateVodSessionRequest;
3031
use Google\Cloud\Video\Stitcher\V1\VodSession;
3132

3233
/**
@@ -57,7 +58,10 @@ function create_vod_session(
5758
$vodSession->setAdTracking(AdTracking::SERVER);
5859

5960
// Run VOD session creation request
60-
$response = $stitcherClient->createVodSession($parent, $vodSession);
61+
$request = (new CreateVodSessionRequest())
62+
->setParent($parent)
63+
->setVodSession($vodSession);
64+
$response = $stitcherClient->createVodSession($request);
6165

6266
// Print results
6367
printf('VOD session: %s' . PHP_EOL, $response->getName());

media/videostitcher/src/delete_cdn_key.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_delete_cdn_key]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
28+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
29+
use Google\Cloud\Video\Stitcher\V1\DeleteCdnKeyRequest;
2930

3031
/**
3132
* Deletes a CDN key.
@@ -43,7 +44,9 @@ function delete_cdn_key(
4344
$stitcherClient = new VideoStitcherServiceClient();
4445

4546
$formattedName = $stitcherClient->cdnKeyName($callingProjectId, $location, $cdnKeyId);
46-
$operationResponse = $stitcherClient->deleteCdnKey($formattedName);
47+
$request = (new DeleteCdnKeyRequest())
48+
->setName($formattedName);
49+
$operationResponse = $stitcherClient->deleteCdnKey($request);
4750
$operationResponse->pollUntilComplete();
4851
if ($operationResponse->operationSucceeded()) {
4952
// Print status

media/videostitcher/src/delete_live_config.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_delete_live_config]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
28+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
29+
use Google\Cloud\Video\Stitcher\V1\DeleteLiveConfigRequest;
2930

3031
/**
3132
* Deletes a live config.
@@ -43,7 +44,9 @@ function delete_live_config(
4344
$stitcherClient = new VideoStitcherServiceClient();
4445

4546
$formattedName = $stitcherClient->liveConfigName($callingProjectId, $location, $liveConfigId);
46-
$operationResponse = $stitcherClient->deleteLiveConfig($formattedName);
47+
$request = (new DeleteLiveConfigRequest())
48+
->setName($formattedName);
49+
$operationResponse = $stitcherClient->deleteLiveConfig($request);
4750
$operationResponse->pollUntilComplete();
4851
if ($operationResponse->operationSucceeded()) {
4952
// Print status

media/videostitcher/src/delete_slate.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_delete_slate]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
28+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
29+
use Google\Cloud\Video\Stitcher\V1\DeleteSlateRequest;
2930

3031
/**
3132
* Deletes a slate.
@@ -43,7 +44,9 @@ function delete_slate(
4344
$stitcherClient = new VideoStitcherServiceClient();
4445

4546
$formattedName = $stitcherClient->slateName($callingProjectId, $location, $slateId);
46-
$operationResponse = $stitcherClient->deleteSlate($formattedName);
47+
$request = (new DeleteSlateRequest())
48+
->setName($formattedName);
49+
$operationResponse = $stitcherClient->deleteSlate($request);
4750
$operationResponse->pollUntilComplete();
4851
if ($operationResponse->operationSucceeded()) {
4952
// Print status

media/videostitcher/src/get_cdn_key.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\Media\Stitcher;
2626

2727
// [START videostitcher_get_cdn_key]
28-
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
28+
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
29+
use Google\Cloud\Video\Stitcher\V1\GetCdnKeyRequest;
2930

3031
/**
3132
* Gets a CDN key.
@@ -43,7 +44,9 @@ function get_cdn_key(
4344
$stitcherClient = new VideoStitcherServiceClient();
4445

4546
$formattedName = $stitcherClient->cdnKeyName($callingProjectId, $location, $cdnKeyId);
46-
$key = $stitcherClient->getCdnKey($formattedName);
47+
$request = (new GetCdnKeyRequest())
48+
->setName($formattedName);
49+
$key = $stitcherClient->getCdnKey($request);
4750

4851
// Print results
4952
printf('CDN key: %s' . PHP_EOL, $key->getName());

0 commit comments

Comments
 (0)