22
22
use Google \ApiCore \ApiException ;
23
23
use Google \Cloud \TestUtils \EventuallyConsistentTestTrait ;
24
24
use Google \Cloud \TestUtils \TestTrait ;
25
- use Google \Cloud \Video \LiveStream \V1 \LivestreamServiceClient ;
25
+ use Google \Cloud \Video \LiveStream \V1 \Client \LivestreamServiceClient ;
26
+ use Google \Cloud \Video \LiveStream \V1 \DeleteAssetRequest ;
27
+ use Google \Cloud \Video \LiveStream \V1 \DeleteChannelRequest ;
28
+ use Google \Cloud \Video \LiveStream \V1 \DeleteEventRequest ;
29
+ use Google \Cloud \Video \LiveStream \V1 \DeleteInputRequest ;
30
+ use Google \Cloud \Video \LiveStream \V1 \GetChannelRequest ;
31
+ use Google \Cloud \Video \LiveStream \V1 \GetInputRequest ;
32
+ use Google \Cloud \Video \LiveStream \V1 \GetPoolRequest ;
33
+ use Google \Cloud \Video \LiveStream \V1 \ListAssetsRequest ;
34
+ use Google \Cloud \Video \LiveStream \V1 \ListChannelsRequest ;
35
+ use Google \Cloud \Video \LiveStream \V1 \ListEventsRequest ;
36
+ use Google \Cloud \Video \LiveStream \V1 \ListInputsRequest ;
37
+ use Google \Cloud \Video \LiveStream \V1 \StopChannelRequest ;
26
38
use PHPUnit \Framework \TestCase ;
27
39
28
40
/**
@@ -107,7 +119,9 @@ public function testUpdateInput()
107
119
self ::$ location ,
108
120
self ::$ inputId
109
121
);
110
- $ input = $ livestreamClient ->getInput ($ formattedName );
122
+ $ getInputRequest = (new GetInputRequest ())
123
+ ->setName ($ formattedName );
124
+ $ input = $ livestreamClient ->getInput ($ getInputRequest );
111
125
$ this ->assertTrue ($ input ->getPreprocessingConfig ()->hasCrop ());
112
126
}
113
127
@@ -198,7 +212,9 @@ public function testUpdateChannel()
198
212
self ::$ location ,
199
213
self ::$ channelId
200
214
);
201
- $ channel = $ livestreamClient ->getChannel ($ formattedName );
215
+ $ getChannelRequest = (new GetChannelRequest ())
216
+ ->setName ($ formattedName );
217
+ $ channel = $ livestreamClient ->getChannel ($ getChannelRequest );
202
218
$ inputAttachments = $ channel ->getInputAttachments ();
203
219
foreach ($ inputAttachments as $ inputAttachment ) {
204
220
$ this ->assertStringContainsString ('updated-input ' , $ inputAttachment ->getKey ());
@@ -476,15 +492,19 @@ public function testUpdatePool()
476
492
self ::$ location ,
477
493
self ::$ poolId
478
494
);
479
- $ pool = $ livestreamClient ->getPool ($ formattedName );
495
+ $ getPoolRequest = (new GetPoolRequest ())
496
+ ->setName ($ formattedName );
497
+ $ pool = $ livestreamClient ->getPool ($ getPoolRequest );
480
498
$ this ->assertEquals ($ pool ->getNetworkConfig ()->getPeeredNetwork (), '' );
481
499
}
482
500
483
501
private static function deleteOldInputs (): void
484
502
{
485
503
$ livestreamClient = new LivestreamServiceClient ();
486
504
$ parent = $ livestreamClient ->locationName (self ::$ projectId , self ::$ location );
487
- $ response = $ livestreamClient ->listInputs ($ parent );
505
+ $ listInputsRequest = (new ListInputsRequest ())
506
+ ->setParent ($ parent );
507
+ $ response = $ livestreamClient ->listInputs ($ listInputsRequest );
488
508
$ inputs = $ response ->iterateAllElements ();
489
509
490
510
$ currentTime = time ();
@@ -498,7 +518,9 @@ private static function deleteOldInputs(): void
498
518
499
519
if ($ currentTime - $ timestamp >= $ oneHourInSecs ) {
500
520
try {
501
- $ livestreamClient ->deleteInput ($ input ->getName ());
521
+ $ deleteInputRequest = (new DeleteInputRequest ())
522
+ ->setName ($ input ->getName ());
523
+ $ livestreamClient ->deleteInput ($ deleteInputRequest );
502
524
} catch (ApiException $ e ) {
503
525
// Cannot delete inputs that are added to channels
504
526
if ($ e ->getStatus () === 'FAILED_PRECONDITION ' ) {
@@ -515,7 +537,9 @@ private static function deleteOldChannels(): void
515
537
{
516
538
$ livestreamClient = new LivestreamServiceClient ();
517
539
$ parent = $ livestreamClient ->locationName (self ::$ projectId , self ::$ location );
518
- $ response = $ livestreamClient ->listChannels ($ parent );
540
+ $ listChannelsRequest = (new ListChannelsRequest ())
541
+ ->setParent ($ parent );
542
+ $ response = $ livestreamClient ->listChannels ($ listChannelsRequest );
519
543
$ channels = $ response ->iterateAllElements ();
520
544
521
545
$ currentTime = time ();
@@ -529,18 +553,24 @@ private static function deleteOldChannels(): void
529
553
530
554
if ($ currentTime - $ timestamp >= $ oneHourInSecs ) {
531
555
// Must delete channel events before deleting the channel
532
- $ response = $ livestreamClient ->listEvents ($ channel ->getName ());
556
+ $ listEventsRequest = (new ListEventsRequest ())
557
+ ->setParent ($ channel ->getName ());
558
+ $ response = $ livestreamClient ->listEvents ($ listEventsRequest );
533
559
$ events = $ response ->iterateAllElements ();
534
560
foreach ($ events as $ event ) {
535
561
try {
536
- $ livestreamClient ->deleteEvent ($ event ->getName ());
562
+ $ deleteEventRequest = (new DeleteEventRequest ())
563
+ ->setName ($ event ->getName ());
564
+ $ livestreamClient ->deleteEvent ($ deleteEventRequest );
537
565
} catch (ApiException $ e ) {
538
566
printf ('Channel event delete failed: %s. ' . PHP_EOL , $ e ->getMessage ());
539
567
}
540
568
}
541
569
542
570
try {
543
- $ livestreamClient ->stopChannel ($ channel ->getName ());
571
+ $ stopChannelRequest = (new StopChannelRequest ())
572
+ ->setName ($ channel ->getName ());
573
+ $ livestreamClient ->stopChannel ($ stopChannelRequest );
544
574
} catch (ApiException $ e ) {
545
575
// Cannot delete channels that are running, but
546
576
// channel may already be stopped
@@ -552,7 +582,9 @@ private static function deleteOldChannels(): void
552
582
}
553
583
554
584
try {
555
- $ livestreamClient ->deleteChannel ($ channel ->getName ());
585
+ $ deleteChannelRequest = (new DeleteChannelRequest ())
586
+ ->setName ($ channel ->getName ());
587
+ $ livestreamClient ->deleteChannel ($ deleteChannelRequest );
556
588
} catch (ApiException $ e ) {
557
589
// Cannot delete inputs that are added to channels
558
590
if ($ e ->getStatus () === 'FAILED_PRECONDITION ' ) {
@@ -569,7 +601,9 @@ private static function deleteOldAssets(): void
569
601
{
570
602
$ livestreamClient = new LivestreamServiceClient ();
571
603
$ parent = $ livestreamClient ->locationName (self ::$ projectId , self ::$ location );
572
- $ response = $ livestreamClient ->listAssets ($ parent );
604
+ $ listAssetsRequest = (new ListAssetsRequest ())
605
+ ->setParent ($ parent );
606
+ $ response = $ livestreamClient ->listAssets ($ listAssetsRequest );
573
607
$ assets = $ response ->iterateAllElements ();
574
608
575
609
$ currentTime = time ();
@@ -583,7 +617,9 @@ private static function deleteOldAssets(): void
583
617
584
618
if ($ currentTime - $ timestamp >= $ oneHourInSecs ) {
585
619
try {
586
- $ livestreamClient ->deleteAsset ($ asset ->getName ());
620
+ $ deleteAssetRequest = (new DeleteAssetRequest ())
621
+ ->setName ($ asset ->getName ());
622
+ $ livestreamClient ->deleteAsset ($ deleteAssetRequest );
587
623
} catch (ApiException $ e ) {
588
624
printf ('Asset delete failed: %s. ' . PHP_EOL , $ e ->getMessage ());
589
625
}
0 commit comments