From d35bb12008399bf61b37bf7f24792db69cf54f0c Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 23 Jun 2022 21:30:21 +0000 Subject: [PATCH] feat: Enable REST transport for most of Java and Go clients (#60) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 456641589 Source-Link: https://github.com/googleapis/googleapis/commit/8a251f5225b789b2383207ffd978f6aa3d77fcf7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4ca52a529cf01308d9714950edffbea3560cfbdb Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGNhNTJhNTI5Y2YwMTMwOGQ5NzE0OTUwZWRmZmJlYTM1NjBjZmJkYiJ9 --- .../google-cloud-live-stream/pom.xml | 16 + .../v1/LivestreamServiceClient.java | 38 +- .../v1/LivestreamServiceSettings.java | 23 +- ...pJsonLivestreamServiceCallableFactory.java | 105 ++ .../stub/HttpJsonLivestreamServiceStub.java | 1158 ++++++++++++ .../v1/stub/LivestreamServiceStub.java | 6 +- .../stub/LivestreamServiceStubSettings.java | 53 +- .../LivestreamServiceClientHttpJsonTest.java | 1679 +++++++++++++++++ .../SyncCreateSetCredentialsProvider.java | 42 + .../SyncCreateSetCredentialsProvider1.java | 41 + .../create/SyncCreateSetEndpoint.java | 39 + .../createchannel/AsyncCreateChannel.java | 51 + .../createchannel/AsyncCreateChannelLRO.java | 51 + .../createchannel/SyncCreateChannel.java | 46 + ...reateChannelLocationnameChannelString.java | 44 + .../SyncCreateChannelStringChannelString.java | 42 + .../createevent/AsyncCreateEvent.java | 49 + .../createevent/SyncCreateEvent.java | 46 + ...SyncCreateEventChannelnameEventString.java | 41 + .../SyncCreateEventStringEventString.java | 41 + .../createinput/AsyncCreateInput.java | 51 + .../createinput/AsyncCreateInputLRO.java | 51 + .../createinput/SyncCreateInput.java | 46 + ...yncCreateInputLocationnameInputString.java | 41 + .../SyncCreateInputStringInputString.java | 41 + .../deletechannel/AsyncDeleteChannel.java | 49 + .../deletechannel/AsyncDeleteChannelLRO.java | 50 + .../deletechannel/SyncDeleteChannel.java | 44 + .../SyncDeleteChannelChannelname.java | 38 + .../SyncDeleteChannelString.java | 38 + .../deleteevent/AsyncDeleteEvent.java | 47 + .../deleteevent/SyncDeleteEvent.java | 43 + .../deleteevent/SyncDeleteEventEventname.java | 38 + .../deleteevent/SyncDeleteEventString.java | 38 + .../deleteinput/AsyncDeleteInput.java | 48 + .../deleteinput/AsyncDeleteInputLRO.java | 49 + .../deleteinput/SyncDeleteInput.java | 43 + .../deleteinput/SyncDeleteInputInputname.java | 38 + .../deleteinput/SyncDeleteInputString.java | 38 + .../getchannel/AsyncGetChannel.java | 46 + .../getchannel/SyncGetChannel.java | 43 + .../getchannel/SyncGetChannelChannelname.java | 39 + .../getchannel/SyncGetChannelString.java | 39 + .../getevent/AsyncGetEvent.java | 46 + .../getevent/SyncGetEvent.java | 43 + .../getevent/SyncGetEventEventname.java | 39 + .../getevent/SyncGetEventString.java | 39 + .../getinput/AsyncGetInput.java | 46 + .../getinput/SyncGetInput.java | 43 + .../getinput/SyncGetInputInputname.java | 39 + .../getinput/SyncGetInputString.java | 39 + .../listchannels/AsyncListChannels.java | 53 + .../listchannels/AsyncListChannelsPaged.java | 61 + .../listchannels/SyncListChannels.java | 49 + .../SyncListChannelsLocationname.java | 41 + .../listchannels/SyncListChannelsString.java | 41 + .../listevents/AsyncListEvents.java | 53 + .../listevents/AsyncListEventsPaged.java | 60 + .../listevents/SyncListEvents.java | 49 + .../listevents/SyncListEventsChannelname.java | 41 + .../listevents/SyncListEventsString.java | 41 + .../listinputs/AsyncListInputs.java | 53 + .../listinputs/AsyncListInputsPaged.java | 60 + .../listinputs/SyncListInputs.java | 49 + .../SyncListInputsLocationname.java | 41 + .../listinputs/SyncListInputsString.java | 41 + .../startchannel/AsyncStartChannel.java | 48 + .../startchannel/AsyncStartChannelLRO.java | 49 + .../startchannel/SyncStartChannel.java | 44 + .../SyncStartChannelChannelname.java | 39 + .../startchannel/SyncStartChannelString.java | 39 + .../stopchannel/AsyncStopChannel.java | 48 + .../stopchannel/AsyncStopChannelLRO.java | 49 + .../stopchannel/SyncStopChannel.java | 44 + .../SyncStopChannelChannelname.java | 39 + .../stopchannel/SyncStopChannelString.java | 39 + .../updatechannel/AsyncUpdateChannel.java | 50 + .../updatechannel/AsyncUpdateChannelLRO.java | 50 + .../updatechannel/SyncUpdateChannel.java | 45 + .../SyncUpdateChannelChannelFieldmask.java | 40 + .../updateinput/AsyncUpdateInput.java | 50 + .../updateinput/AsyncUpdateInputLRO.java | 50 + .../updateinput/SyncUpdateInput.java | 45 + .../SyncUpdateInputInputFieldmask.java | 40 + .../getchannel/SyncGetChannel.java | 46 + .../getchannel/SyncGetChannel.java | 47 + 86 files changed, 6566 insertions(+), 11 deletions(-) create mode 100644 java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/HttpJsonLivestreamServiceCallableFactory.java create mode 100644 java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/HttpJsonLivestreamServiceStub.java create mode 100644 java-video-live-stream/google-cloud-live-stream/src/test/java/com/google/cloud/video/livestream/v1/LivestreamServiceClientHttpJsonTest.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetCredentialsProvider.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetCredentialsProvider1.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetEndpoint.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/AsyncCreateChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/AsyncCreateChannelLRO.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannelLocationnameChannelString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannelStringChannelString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/AsyncCreateEvent.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEvent.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEventChannelnameEventString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEventStringEventString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/AsyncCreateInput.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/AsyncCreateInputLRO.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInput.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInputLocationnameInputString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInputStringInputString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/AsyncDeleteChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/AsyncDeleteChannelLRO.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannelChannelname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannelString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/AsyncDeleteEvent.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEvent.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEventEventname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEventString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/AsyncDeleteInput.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/AsyncDeleteInputLRO.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInput.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInputInputname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInputString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/AsyncGetChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannelChannelname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannelString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/AsyncGetEvent.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEvent.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEventEventname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEventString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/AsyncGetInput.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInput.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInputInputname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInputString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/AsyncListChannels.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/AsyncListChannelsPaged.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannels.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannelsLocationname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannelsString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/AsyncListEvents.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/AsyncListEventsPaged.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEvents.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEventsChannelname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEventsString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/AsyncListInputs.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/AsyncListInputsPaged.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputs.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputsLocationname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputsString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/AsyncStartChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/AsyncStartChannelLRO.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannelChannelname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannelString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/AsyncStopChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/AsyncStopChannelLRO.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannelChannelname.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannelString.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/AsyncUpdateChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/AsyncUpdateChannelLRO.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/SyncUpdateChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/SyncUpdateChannelChannelFieldmask.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/AsyncUpdateInput.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/AsyncUpdateInputLRO.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/SyncUpdateInput.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/SyncUpdateInputInputFieldmask.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamservicesettings/getchannel/SyncGetChannel.java create mode 100644 java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/stub/livestreamservicestubsettings/getchannel/SyncGetChannel.java diff --git a/java-video-live-stream/google-cloud-live-stream/pom.xml b/java-video-live-stream/google-cloud-live-stream/pom.xml index 90944327d1eb..8b66b757146b 100644 --- a/java-video-live-stream/google-cloud-live-stream/pom.xml +++ b/java-video-live-stream/google-cloud-live-stream/pom.xml @@ -58,6 +58,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -77,12 +81,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/LivestreamServiceClient.java b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/LivestreamServiceClient.java index 029e58c72ba3..39aa5a0f9884 100644 --- a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/LivestreamServiceClient.java +++ b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/LivestreamServiceClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.video.livestream.v1.stub.LivestreamServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -108,13 +108,29 @@ * LivestreamServiceClient.create(livestreamServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * LivestreamServiceSettings livestreamServiceSettings =
+ *     LivestreamServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             LivestreamServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * LivestreamServiceClient livestreamServiceClient =
+ *     LivestreamServiceClient.create(livestreamServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class LivestreamServiceClient implements BackgroundResource { private final LivestreamServiceSettings settings; private final LivestreamServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of LivestreamServiceClient with default settings. */ public static final LivestreamServiceClient create() throws IOException { @@ -146,13 +162,17 @@ public static final LivestreamServiceClient create(LivestreamServiceStub stub) { protected LivestreamServiceClient(LivestreamServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((LivestreamServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected LivestreamServiceClient(LivestreamServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final LivestreamServiceSettings getSettings() { @@ -167,10 +187,18 @@ public LivestreamServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a channel with the provided unique ID in the specified region. diff --git a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/LivestreamServiceSettings.java b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/LivestreamServiceSettings.java index 9385f4adef5b..b7ad6230785b 100644 --- a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/LivestreamServiceSettings.java +++ b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/LivestreamServiceSettings.java @@ -25,6 +25,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -232,11 +233,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return LivestreamServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return LivestreamServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return LivestreamServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return LivestreamServiceStubSettings.defaultTransportChannelProvider(); } @@ -246,11 +254,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return LivestreamServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -288,6 +302,11 @@ private static Builder createDefault() { return new Builder(LivestreamServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(LivestreamServiceStubSettings.newHttpJsonBuilder()); + } + public LivestreamServiceStubSettings.Builder getStubSettingsBuilder() { return ((LivestreamServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/HttpJsonLivestreamServiceCallableFactory.java b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/HttpJsonLivestreamServiceCallableFactory.java new file mode 100644 index 000000000000..2efbf25b31bb --- /dev/null +++ b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/HttpJsonLivestreamServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the LivestreamService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonLivestreamServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/HttpJsonLivestreamServiceStub.java b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/HttpJsonLivestreamServiceStub.java new file mode 100644 index 000000000000..5202b8780af2 --- /dev/null +++ b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/HttpJsonLivestreamServiceStub.java @@ -0,0 +1,1158 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.stub; + +import static com.google.cloud.video.livestream.v1.LivestreamServiceClient.ListChannelsPagedResponse; +import static com.google.cloud.video.livestream.v1.LivestreamServiceClient.ListEventsPagedResponse; +import static com.google.cloud.video.livestream.v1.LivestreamServiceClient.ListInputsPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.CreateChannelRequest; +import com.google.cloud.video.livestream.v1.CreateEventRequest; +import com.google.cloud.video.livestream.v1.CreateInputRequest; +import com.google.cloud.video.livestream.v1.DeleteChannelRequest; +import com.google.cloud.video.livestream.v1.DeleteEventRequest; +import com.google.cloud.video.livestream.v1.DeleteInputRequest; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.GetChannelRequest; +import com.google.cloud.video.livestream.v1.GetEventRequest; +import com.google.cloud.video.livestream.v1.GetInputRequest; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.ListChannelsRequest; +import com.google.cloud.video.livestream.v1.ListChannelsResponse; +import com.google.cloud.video.livestream.v1.ListEventsRequest; +import com.google.cloud.video.livestream.v1.ListEventsResponse; +import com.google.cloud.video.livestream.v1.ListInputsRequest; +import com.google.cloud.video.livestream.v1.ListInputsResponse; +import com.google.cloud.video.livestream.v1.OperationMetadata; +import com.google.cloud.video.livestream.v1.StartChannelRequest; +import com.google.cloud.video.livestream.v1.StopChannelRequest; +import com.google.cloud.video.livestream.v1.UpdateChannelRequest; +import com.google.cloud.video.livestream.v1.UpdateInputRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the LivestreamService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonLivestreamServiceStub extends LivestreamServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .add(Channel.getDescriptor()) + .add(Input.getDescriptor()) + .add(ChannelOperationResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createChannelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/CreateChannel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/channels", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "channelId", request.getChannelId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("channel", request.getChannel())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateChannelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listChannelsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/ListChannels") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/channels", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListChannelsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getChannelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/GetChannel") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/channels/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Channel.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteChannelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/DeleteChannel") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/channels/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteChannelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateChannelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/UpdateChannel") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{channel.name=projects/*/locations/*/channels/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "channel.name", request.getChannel().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("channel", request.getChannel())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateChannelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + startChannelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/StartChannel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/channels/*}:start", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (StartChannelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + stopChannelMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/StopChannel") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/channels/*}:stop", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (StopChannelRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createInputMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/CreateInput") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/inputs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "inputId", request.getInputId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("input", request.getInput())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateInputRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listInputsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/ListInputs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/inputs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInputsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getInputMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/GetInput") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/inputs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Input.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteInputMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/DeleteInput") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/inputs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteInputRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateInputMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/UpdateInput") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{input.name=projects/*/locations/*/inputs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "input.name", request.getInput().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("input", request.getInput())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateInputRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor createEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/CreateEvent") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/channels/*}/events", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "eventId", request.getEventId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> ProtoRestSerializer.create().toBody("event", request.getEvent())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Event.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listEventsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/ListEvents") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/channels/*}/events", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListEventsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/GetEvent") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/channels/*/events/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Event.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteEventMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.video.livestream.v1.LivestreamService/DeleteEvent") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/channels/*/events/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createChannelCallable; + private final OperationCallable + createChannelOperationCallable; + private final UnaryCallable listChannelsCallable; + private final UnaryCallable + listChannelsPagedCallable; + private final UnaryCallable getChannelCallable; + private final UnaryCallable deleteChannelCallable; + private final OperationCallable + deleteChannelOperationCallable; + private final UnaryCallable updateChannelCallable; + private final OperationCallable + updateChannelOperationCallable; + private final UnaryCallable startChannelCallable; + private final OperationCallable + startChannelOperationCallable; + private final UnaryCallable stopChannelCallable; + private final OperationCallable + stopChannelOperationCallable; + private final UnaryCallable createInputCallable; + private final OperationCallable + createInputOperationCallable; + private final UnaryCallable listInputsCallable; + private final UnaryCallable listInputsPagedCallable; + private final UnaryCallable getInputCallable; + private final UnaryCallable deleteInputCallable; + private final OperationCallable + deleteInputOperationCallable; + private final UnaryCallable updateInputCallable; + private final OperationCallable + updateInputOperationCallable; + private final UnaryCallable createEventCallable; + private final UnaryCallable listEventsCallable; + private final UnaryCallable listEventsPagedCallable; + private final UnaryCallable getEventCallable; + private final UnaryCallable deleteEventCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonLivestreamServiceStub create(LivestreamServiceStubSettings settings) + throws IOException { + return new HttpJsonLivestreamServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonLivestreamServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonLivestreamServiceStub( + LivestreamServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonLivestreamServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonLivestreamServiceStub( + LivestreamServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonLivestreamServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonLivestreamServiceStub( + LivestreamServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonLivestreamServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonLivestreamServiceStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonLivestreamServiceStub( + LivestreamServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createChannelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createChannelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listChannelsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listChannelsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getChannelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getChannelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteChannelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteChannelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateChannelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateChannelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings startChannelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(startChannelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings stopChannelTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(stopChannelMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createInputTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createInputMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listInputsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInputsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInputTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInputMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteInputTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteInputMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateInputTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateInputMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listEventsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listEventsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteEventTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteEventMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createChannelCallable = + callableFactory.createUnaryCallable( + createChannelTransportSettings, settings.createChannelSettings(), clientContext); + this.createChannelOperationCallable = + callableFactory.createOperationCallable( + createChannelTransportSettings, + settings.createChannelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listChannelsCallable = + callableFactory.createUnaryCallable( + listChannelsTransportSettings, settings.listChannelsSettings(), clientContext); + this.listChannelsPagedCallable = + callableFactory.createPagedCallable( + listChannelsTransportSettings, settings.listChannelsSettings(), clientContext); + this.getChannelCallable = + callableFactory.createUnaryCallable( + getChannelTransportSettings, settings.getChannelSettings(), clientContext); + this.deleteChannelCallable = + callableFactory.createUnaryCallable( + deleteChannelTransportSettings, settings.deleteChannelSettings(), clientContext); + this.deleteChannelOperationCallable = + callableFactory.createOperationCallable( + deleteChannelTransportSettings, + settings.deleteChannelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateChannelCallable = + callableFactory.createUnaryCallable( + updateChannelTransportSettings, settings.updateChannelSettings(), clientContext); + this.updateChannelOperationCallable = + callableFactory.createOperationCallable( + updateChannelTransportSettings, + settings.updateChannelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.startChannelCallable = + callableFactory.createUnaryCallable( + startChannelTransportSettings, settings.startChannelSettings(), clientContext); + this.startChannelOperationCallable = + callableFactory.createOperationCallable( + startChannelTransportSettings, + settings.startChannelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.stopChannelCallable = + callableFactory.createUnaryCallable( + stopChannelTransportSettings, settings.stopChannelSettings(), clientContext); + this.stopChannelOperationCallable = + callableFactory.createOperationCallable( + stopChannelTransportSettings, + settings.stopChannelOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createInputCallable = + callableFactory.createUnaryCallable( + createInputTransportSettings, settings.createInputSettings(), clientContext); + this.createInputOperationCallable = + callableFactory.createOperationCallable( + createInputTransportSettings, + settings.createInputOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listInputsCallable = + callableFactory.createUnaryCallable( + listInputsTransportSettings, settings.listInputsSettings(), clientContext); + this.listInputsPagedCallable = + callableFactory.createPagedCallable( + listInputsTransportSettings, settings.listInputsSettings(), clientContext); + this.getInputCallable = + callableFactory.createUnaryCallable( + getInputTransportSettings, settings.getInputSettings(), clientContext); + this.deleteInputCallable = + callableFactory.createUnaryCallable( + deleteInputTransportSettings, settings.deleteInputSettings(), clientContext); + this.deleteInputOperationCallable = + callableFactory.createOperationCallable( + deleteInputTransportSettings, + settings.deleteInputOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateInputCallable = + callableFactory.createUnaryCallable( + updateInputTransportSettings, settings.updateInputSettings(), clientContext); + this.updateInputOperationCallable = + callableFactory.createOperationCallable( + updateInputTransportSettings, + settings.updateInputOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createEventCallable = + callableFactory.createUnaryCallable( + createEventTransportSettings, settings.createEventSettings(), clientContext); + this.listEventsCallable = + callableFactory.createUnaryCallable( + listEventsTransportSettings, settings.listEventsSettings(), clientContext); + this.listEventsPagedCallable = + callableFactory.createPagedCallable( + listEventsTransportSettings, settings.listEventsSettings(), clientContext); + this.getEventCallable = + callableFactory.createUnaryCallable( + getEventTransportSettings, settings.getEventSettings(), clientContext); + this.deleteEventCallable = + callableFactory.createUnaryCallable( + deleteEventTransportSettings, settings.deleteEventSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createChannelMethodDescriptor); + methodDescriptors.add(listChannelsMethodDescriptor); + methodDescriptors.add(getChannelMethodDescriptor); + methodDescriptors.add(deleteChannelMethodDescriptor); + methodDescriptors.add(updateChannelMethodDescriptor); + methodDescriptors.add(startChannelMethodDescriptor); + methodDescriptors.add(stopChannelMethodDescriptor); + methodDescriptors.add(createInputMethodDescriptor); + methodDescriptors.add(listInputsMethodDescriptor); + methodDescriptors.add(getInputMethodDescriptor); + methodDescriptors.add(deleteInputMethodDescriptor); + methodDescriptors.add(updateInputMethodDescriptor); + methodDescriptors.add(createEventMethodDescriptor); + methodDescriptors.add(listEventsMethodDescriptor); + methodDescriptors.add(getEventMethodDescriptor); + methodDescriptors.add(deleteEventMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createChannelCallable() { + return createChannelCallable; + } + + @Override + public OperationCallable + createChannelOperationCallable() { + return createChannelOperationCallable; + } + + @Override + public UnaryCallable listChannelsCallable() { + return listChannelsCallable; + } + + @Override + public UnaryCallable listChannelsPagedCallable() { + return listChannelsPagedCallable; + } + + @Override + public UnaryCallable getChannelCallable() { + return getChannelCallable; + } + + @Override + public UnaryCallable deleteChannelCallable() { + return deleteChannelCallable; + } + + @Override + public OperationCallable + deleteChannelOperationCallable() { + return deleteChannelOperationCallable; + } + + @Override + public UnaryCallable updateChannelCallable() { + return updateChannelCallable; + } + + @Override + public OperationCallable + updateChannelOperationCallable() { + return updateChannelOperationCallable; + } + + @Override + public UnaryCallable startChannelCallable() { + return startChannelCallable; + } + + @Override + public OperationCallable + startChannelOperationCallable() { + return startChannelOperationCallable; + } + + @Override + public UnaryCallable stopChannelCallable() { + return stopChannelCallable; + } + + @Override + public OperationCallable + stopChannelOperationCallable() { + return stopChannelOperationCallable; + } + + @Override + public UnaryCallable createInputCallable() { + return createInputCallable; + } + + @Override + public OperationCallable + createInputOperationCallable() { + return createInputOperationCallable; + } + + @Override + public UnaryCallable listInputsCallable() { + return listInputsCallable; + } + + @Override + public UnaryCallable listInputsPagedCallable() { + return listInputsPagedCallable; + } + + @Override + public UnaryCallable getInputCallable() { + return getInputCallable; + } + + @Override + public UnaryCallable deleteInputCallable() { + return deleteInputCallable; + } + + @Override + public OperationCallable + deleteInputOperationCallable() { + return deleteInputOperationCallable; + } + + @Override + public UnaryCallable updateInputCallable() { + return updateInputCallable; + } + + @Override + public OperationCallable + updateInputOperationCallable() { + return updateInputOperationCallable; + } + + @Override + public UnaryCallable createEventCallable() { + return createEventCallable; + } + + @Override + public UnaryCallable listEventsCallable() { + return listEventsCallable; + } + + @Override + public UnaryCallable listEventsPagedCallable() { + return listEventsPagedCallable; + } + + @Override + public UnaryCallable getEventCallable() { + return getEventCallable; + } + + @Override + public UnaryCallable deleteEventCallable() { + return deleteEventCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/LivestreamServiceStub.java b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/LivestreamServiceStub.java index 6ee4ecccff01..bd3c9e988417 100644 --- a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/LivestreamServiceStub.java +++ b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/LivestreamServiceStub.java @@ -62,7 +62,11 @@ public abstract class LivestreamServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public OperationCallable diff --git a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/LivestreamServiceStubSettings.java b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/LivestreamServiceStubSettings.java index 307781e459f5..410074234a24 100644 --- a/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/LivestreamServiceStubSettings.java +++ b/java-video-live-stream/google-cloud-live-stream/src/main/java/com/google/cloud/video/livestream/v1/stub/LivestreamServiceStubSettings.java @@ -30,6 +30,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -457,6 +460,11 @@ public LivestreamServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcLivestreamServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonLivestreamServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -489,18 +497,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(LivestreamServiceStubSettings.class)) @@ -508,11 +523,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(LivestreamServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return LivestreamServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -750,6 +784,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .createChannelSettings() diff --git a/java-video-live-stream/google-cloud-live-stream/src/test/java/com/google/cloud/video/livestream/v1/LivestreamServiceClientHttpJsonTest.java b/java-video-live-stream/google-cloud-live-stream/src/test/java/com/google/cloud/video/livestream/v1/LivestreamServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..1131d2bd02c0 --- /dev/null +++ b/java-video-live-stream/google-cloud-live-stream/src/test/java/com/google/cloud/video/livestream/v1/LivestreamServiceClientHttpJsonTest.java @@ -0,0 +1,1679 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1; + +import static com.google.cloud.video.livestream.v1.LivestreamServiceClient.ListChannelsPagedResponse; +import static com.google.cloud.video.livestream.v1.LivestreamServiceClient.ListEventsPagedResponse; +import static com.google.cloud.video.livestream.v1.LivestreamServiceClient.ListInputsPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.video.livestream.v1.stub.HttpJsonLivestreamServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class LivestreamServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static LivestreamServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonLivestreamServiceStub.getMethodDescriptors(), + LivestreamServiceSettings.getDefaultEndpoint()); + LivestreamServiceSettings settings = + LivestreamServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + LivestreamServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = LivestreamServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createChannelTest() throws Exception { + Channel expectedResponse = + Channel.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllInputAttachments(new ArrayList()) + .setActiveInput("activeInput-1071817628") + .setOutput(Channel.Output.newBuilder().build()) + .addAllElementaryStreams(new ArrayList()) + .addAllMuxStreams(new ArrayList()) + .addAllManifests(new ArrayList()) + .addAllSpriteSheets(new ArrayList()) + .setStreamingError(Status.newBuilder().build()) + .setLogConfig(LogConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Channel channel = Channel.newBuilder().build(); + String channelId = "channelId1461735806"; + + Channel actualResponse = client.createChannelAsync(parent, channel, channelId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createChannelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Channel channel = Channel.newBuilder().build(); + String channelId = "channelId1461735806"; + client.createChannelAsync(parent, channel, channelId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createChannelTest2() throws Exception { + Channel expectedResponse = + Channel.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllInputAttachments(new ArrayList()) + .setActiveInput("activeInput-1071817628") + .setOutput(Channel.Output.newBuilder().build()) + .addAllElementaryStreams(new ArrayList()) + .addAllMuxStreams(new ArrayList()) + .addAllManifests(new ArrayList()) + .addAllSpriteSheets(new ArrayList()) + .setStreamingError(Status.newBuilder().build()) + .setLogConfig(LogConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Channel channel = Channel.newBuilder().build(); + String channelId = "channelId1461735806"; + + Channel actualResponse = client.createChannelAsync(parent, channel, channelId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createChannelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Channel channel = Channel.newBuilder().build(); + String channelId = "channelId1461735806"; + client.createChannelAsync(parent, channel, channelId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listChannelsTest() throws Exception { + Channel responsesElement = Channel.newBuilder().build(); + ListChannelsResponse expectedResponse = + ListChannelsResponse.newBuilder() + .setNextPageToken("") + .addAllChannels(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListChannelsPagedResponse pagedListResponse = client.listChannels(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getChannelsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listChannelsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listChannels(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listChannelsTest2() throws Exception { + Channel responsesElement = Channel.newBuilder().build(); + ListChannelsResponse expectedResponse = + ListChannelsResponse.newBuilder() + .setNextPageToken("") + .addAllChannels(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListChannelsPagedResponse pagedListResponse = client.listChannels(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getChannelsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listChannelsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listChannels(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getChannelTest() throws Exception { + Channel expectedResponse = + Channel.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllInputAttachments(new ArrayList()) + .setActiveInput("activeInput-1071817628") + .setOutput(Channel.Output.newBuilder().build()) + .addAllElementaryStreams(new ArrayList()) + .addAllMuxStreams(new ArrayList()) + .addAllManifests(new ArrayList()) + .addAllSpriteSheets(new ArrayList()) + .setStreamingError(Status.newBuilder().build()) + .setLogConfig(LogConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + + Channel actualResponse = client.getChannel(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getChannelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + client.getChannel(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getChannelTest2() throws Exception { + Channel expectedResponse = + Channel.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllInputAttachments(new ArrayList()) + .setActiveInput("activeInput-1071817628") + .setOutput(Channel.Output.newBuilder().build()) + .addAllElementaryStreams(new ArrayList()) + .addAllMuxStreams(new ArrayList()) + .addAllManifests(new ArrayList()) + .addAllSpriteSheets(new ArrayList()) + .setStreamingError(Status.newBuilder().build()) + .setLogConfig(LogConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3296/locations/location-3296/channels/channel-3296"; + + Channel actualResponse = client.getChannel(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getChannelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3296/locations/location-3296/channels/channel-3296"; + client.getChannel(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteChannelTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + + client.deleteChannelAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteChannelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + client.deleteChannelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteChannelTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3296/locations/location-3296/channels/channel-3296"; + + client.deleteChannelAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteChannelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3296/locations/location-3296/channels/channel-3296"; + client.deleteChannelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateChannelTest() throws Exception { + Channel expectedResponse = + Channel.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllInputAttachments(new ArrayList()) + .setActiveInput("activeInput-1071817628") + .setOutput(Channel.Output.newBuilder().build()) + .addAllElementaryStreams(new ArrayList()) + .addAllMuxStreams(new ArrayList()) + .addAllManifests(new ArrayList()) + .addAllSpriteSheets(new ArrayList()) + .setStreamingError(Status.newBuilder().build()) + .setLogConfig(LogConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Channel channel = + Channel.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllInputAttachments(new ArrayList()) + .setActiveInput("activeInput-1071817628") + .setOutput(Channel.Output.newBuilder().build()) + .addAllElementaryStreams(new ArrayList()) + .addAllMuxStreams(new ArrayList()) + .addAllManifests(new ArrayList()) + .addAllSpriteSheets(new ArrayList()) + .setStreamingError(Status.newBuilder().build()) + .setLogConfig(LogConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Channel actualResponse = client.updateChannelAsync(channel, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateChannelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Channel channel = + Channel.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllInputAttachments(new ArrayList()) + .setActiveInput("activeInput-1071817628") + .setOutput(Channel.Output.newBuilder().build()) + .addAllElementaryStreams(new ArrayList()) + .addAllMuxStreams(new ArrayList()) + .addAllManifests(new ArrayList()) + .addAllSpriteSheets(new ArrayList()) + .setStreamingError(Status.newBuilder().build()) + .setLogConfig(LogConfig.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateChannelAsync(channel, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void startChannelTest() throws Exception { + ChannelOperationResponse expectedResponse = ChannelOperationResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("startChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + + ChannelOperationResponse actualResponse = client.startChannelAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void startChannelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + client.startChannelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void startChannelTest2() throws Exception { + ChannelOperationResponse expectedResponse = ChannelOperationResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("startChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3296/locations/location-3296/channels/channel-3296"; + + ChannelOperationResponse actualResponse = client.startChannelAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void startChannelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3296/locations/location-3296/channels/channel-3296"; + client.startChannelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void stopChannelTest() throws Exception { + ChannelOperationResponse expectedResponse = ChannelOperationResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("stopChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + + ChannelOperationResponse actualResponse = client.stopChannelAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void stopChannelExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + client.stopChannelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void stopChannelTest2() throws Exception { + ChannelOperationResponse expectedResponse = ChannelOperationResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("stopChannelTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3296/locations/location-3296/channels/channel-3296"; + + ChannelOperationResponse actualResponse = client.stopChannelAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void stopChannelExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3296/locations/location-3296/channels/channel-3296"; + client.stopChannelAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createInputTest() throws Exception { + Input expectedResponse = + Input.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setUri("uri116076") + .setPreprocessingConfig(PreprocessingConfig.newBuilder().build()) + .setSecurityRules(Input.SecurityRule.newBuilder().build()) + .setInputStreamProperty(InputStreamProperty.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInputTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Input input = Input.newBuilder().build(); + String inputId = "inputId1954846341"; + + Input actualResponse = client.createInputAsync(parent, input, inputId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInputExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Input input = Input.newBuilder().build(); + String inputId = "inputId1954846341"; + client.createInputAsync(parent, input, inputId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createInputTest2() throws Exception { + Input expectedResponse = + Input.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setUri("uri116076") + .setPreprocessingConfig(PreprocessingConfig.newBuilder().build()) + .setSecurityRules(Input.SecurityRule.newBuilder().build()) + .setInputStreamProperty(InputStreamProperty.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInputTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Input input = Input.newBuilder().build(); + String inputId = "inputId1954846341"; + + Input actualResponse = client.createInputAsync(parent, input, inputId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createInputExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Input input = Input.newBuilder().build(); + String inputId = "inputId1954846341"; + client.createInputAsync(parent, input, inputId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listInputsTest() throws Exception { + Input responsesElement = Input.newBuilder().build(); + ListInputsResponse expectedResponse = + ListInputsResponse.newBuilder() + .setNextPageToken("") + .addAllInputs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListInputsPagedResponse pagedListResponse = client.listInputs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInputsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInputsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listInputs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInputsTest2() throws Exception { + Input responsesElement = Input.newBuilder().build(); + ListInputsResponse expectedResponse = + ListInputsResponse.newBuilder() + .setNextPageToken("") + .addAllInputs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListInputsPagedResponse pagedListResponse = client.listInputs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInputsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listInputsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listInputs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInputTest() throws Exception { + Input expectedResponse = + Input.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setUri("uri116076") + .setPreprocessingConfig(PreprocessingConfig.newBuilder().build()) + .setSecurityRules(Input.SecurityRule.newBuilder().build()) + .setInputStreamProperty(InputStreamProperty.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InputName name = InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]"); + + Input actualResponse = client.getInput(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getInputExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InputName name = InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]"); + client.getInput(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInputTest2() throws Exception { + Input expectedResponse = + Input.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setUri("uri116076") + .setPreprocessingConfig(PreprocessingConfig.newBuilder().build()) + .setSecurityRules(Input.SecurityRule.newBuilder().build()) + .setInputStreamProperty(InputStreamProperty.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1641/locations/location-1641/inputs/input-1641"; + + Input actualResponse = client.getInput(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getInputExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1641/locations/location-1641/inputs/input-1641"; + client.getInput(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteInputTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInputTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + InputName name = InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]"); + + client.deleteInputAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInputExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InputName name = InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]"); + client.deleteInputAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInputTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInputTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-1641/locations/location-1641/inputs/input-1641"; + + client.deleteInputAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteInputExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1641/locations/location-1641/inputs/input-1641"; + client.deleteInputAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateInputTest() throws Exception { + Input expectedResponse = + Input.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setUri("uri116076") + .setPreprocessingConfig(PreprocessingConfig.newBuilder().build()) + .setSecurityRules(Input.SecurityRule.newBuilder().build()) + .setInputStreamProperty(InputStreamProperty.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateInputTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Input input = + Input.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setUri("uri116076") + .setPreprocessingConfig(PreprocessingConfig.newBuilder().build()) + .setSecurityRules(Input.SecurityRule.newBuilder().build()) + .setInputStreamProperty(InputStreamProperty.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Input actualResponse = client.updateInputAsync(input, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateInputExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Input input = + Input.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setUri("uri116076") + .setPreprocessingConfig(PreprocessingConfig.newBuilder().build()) + .setSecurityRules(Input.SecurityRule.newBuilder().build()) + .setInputStreamProperty(InputStreamProperty.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateInputAsync(input, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createEventTest() throws Exception { + Event expectedResponse = + Event.newBuilder() + .setName(EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setExecuteNow(true) + .setExecutionTime(Timestamp.newBuilder().build()) + .setError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ChannelName parent = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + Event event = Event.newBuilder().build(); + String eventId = "eventId-1376502443"; + + Event actualResponse = client.createEvent(parent, event, eventId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ChannelName parent = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + Event event = Event.newBuilder().build(); + String eventId = "eventId-1376502443"; + client.createEvent(parent, event, eventId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createEventTest2() throws Exception { + Event expectedResponse = + Event.newBuilder() + .setName(EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setExecuteNow(true) + .setExecutionTime(Timestamp.newBuilder().build()) + .setError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-367/locations/location-367/channels/channel-367"; + Event event = Event.newBuilder().build(); + String eventId = "eventId-1376502443"; + + Event actualResponse = client.createEvent(parent, event, eventId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createEventExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-367/locations/location-367/channels/channel-367"; + Event event = Event.newBuilder().build(); + String eventId = "eventId-1376502443"; + client.createEvent(parent, event, eventId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEventsTest() throws Exception { + Event responsesElement = Event.newBuilder().build(); + ListEventsResponse expectedResponse = + ListEventsResponse.newBuilder() + .setNextPageToken("") + .addAllEvents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ChannelName parent = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + + ListEventsPagedResponse pagedListResponse = client.listEvents(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEventsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEventsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ChannelName parent = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + client.listEvents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listEventsTest2() throws Exception { + Event responsesElement = Event.newBuilder().build(); + ListEventsResponse expectedResponse = + ListEventsResponse.newBuilder() + .setNextPageToken("") + .addAllEvents(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-367/locations/location-367/channels/channel-367"; + + ListEventsPagedResponse pagedListResponse = client.listEvents(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getEventsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listEventsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-367/locations/location-367/channels/channel-367"; + client.listEvents(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEventTest() throws Exception { + Event expectedResponse = + Event.newBuilder() + .setName(EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setExecuteNow(true) + .setExecutionTime(Timestamp.newBuilder().build()) + .setError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + EventName name = EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]"); + + Event actualResponse = client.getEvent(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EventName name = EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]"); + client.getEvent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEventTest2() throws Exception { + Event expectedResponse = + Event.newBuilder() + .setName(EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setExecuteNow(true) + .setExecutionTime(Timestamp.newBuilder().build()) + .setError(Status.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4669/locations/location-4669/channels/channel-4669/events/event-4669"; + + Event actualResponse = client.getEvent(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getEventExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4669/locations/location-4669/channels/channel-4669/events/event-4669"; + client.getEvent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEventTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + EventName name = EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]"); + + client.deleteEvent(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEventExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + EventName name = EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]"); + client.deleteEvent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteEventTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4669/locations/location-4669/channels/channel-4669/events/event-4669"; + + client.deleteEvent(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteEventExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4669/locations/location-4669/channels/channel-4669/events/event-4669"; + client.deleteEvent(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..19a1bc4ed5a3 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LivestreamServiceSettings; +import com.google.cloud.video.livestream.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + LivestreamServiceSettings livestreamServiceSettings = + LivestreamServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + LivestreamServiceClient livestreamServiceClient = + LivestreamServiceClient.create(livestreamServiceSettings); + } +} +// [END livestream_v1_generated_livestreamserviceclient_create_setcredentialsprovider_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..323ea557f64a --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LivestreamServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + LivestreamServiceSettings livestreamServiceSettings = + LivestreamServiceSettings.newBuilder() + .setTransportChannelProvider( + LivestreamServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + LivestreamServiceClient livestreamServiceClient = + LivestreamServiceClient.create(livestreamServiceSettings); + } +} +// [END livestream_v1_generated_livestreamserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetEndpoint.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..b574782a3ec2 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_create_setendpoint_sync] +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LivestreamServiceSettings; +import com.google.cloud.video.livestream.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + LivestreamServiceSettings livestreamServiceSettings = + LivestreamServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + LivestreamServiceClient livestreamServiceClient = + LivestreamServiceClient.create(livestreamServiceSettings); + } +} +// [END livestream_v1_generated_livestreamserviceclient_create_setendpoint_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/AsyncCreateChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/AsyncCreateChannel.java new file mode 100644 index 000000000000..25bc63580d0e --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/AsyncCreateChannel.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createchannel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.CreateChannelRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateChannel { + + public static void main(String[] args) throws Exception { + asyncCreateChannel(); + } + + public static void asyncCreateChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + CreateChannelRequest request = + CreateChannelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setChannel(Channel.newBuilder().build()) + .setChannelId("channelId1461735806") + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + livestreamServiceClient.createChannelCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createchannel_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/AsyncCreateChannelLRO.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/AsyncCreateChannelLRO.java new file mode 100644 index 000000000000..1ba79da44650 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/AsyncCreateChannelLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createchannel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.CreateChannelRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; +import com.google.cloud.video.livestream.v1.OperationMetadata; + +public class AsyncCreateChannelLRO { + + public static void main(String[] args) throws Exception { + asyncCreateChannelLRO(); + } + + public static void asyncCreateChannelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + CreateChannelRequest request = + CreateChannelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setChannel(Channel.newBuilder().build()) + .setChannelId("channelId1461735806") + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + livestreamServiceClient.createChannelOperationCallable().futureCall(request); + // Do something. + Channel response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createchannel_lro_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannel.java new file mode 100644 index 000000000000..117432a3b00d --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannel.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createchannel_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.CreateChannelRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncCreateChannel { + + public static void main(String[] args) throws Exception { + syncCreateChannel(); + } + + public static void syncCreateChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + CreateChannelRequest request = + CreateChannelRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setChannel(Channel.newBuilder().build()) + .setChannelId("channelId1461735806") + .setRequestId("requestId693933066") + .build(); + Channel response = livestreamServiceClient.createChannelAsync(request).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createchannel_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannelLocationnameChannelString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannelLocationnameChannelString.java new file mode 100644 index 000000000000..51f976fce30f --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannelLocationnameChannelString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START +// livestream_v1_generated_livestreamserviceclient_createchannel_locationnamechannelstring_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncCreateChannelLocationnameChannelString { + + public static void main(String[] args) throws Exception { + syncCreateChannelLocationnameChannelString(); + } + + public static void syncCreateChannelLocationnameChannelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Channel channel = Channel.newBuilder().build(); + String channelId = "channelId1461735806"; + Channel response = + livestreamServiceClient.createChannelAsync(parent, channel, channelId).get(); + } + } +} +// [END +// livestream_v1_generated_livestreamserviceclient_createchannel_locationnamechannelstring_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannelStringChannelString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannelStringChannelString.java new file mode 100644 index 000000000000..7abcc571bf2d --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createchannel/SyncCreateChannelStringChannelString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createchannel_stringchannelstring_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncCreateChannelStringChannelString { + + public static void main(String[] args) throws Exception { + syncCreateChannelStringChannelString(); + } + + public static void syncCreateChannelStringChannelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Channel channel = Channel.newBuilder().build(); + String channelId = "channelId1461735806"; + Channel response = + livestreamServiceClient.createChannelAsync(parent, channel, channelId).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createchannel_stringchannelstring_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/AsyncCreateEvent.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/AsyncCreateEvent.java new file mode 100644 index 000000000000..6de58f7bc6b2 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/AsyncCreateEvent.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.CreateEventRequest; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class AsyncCreateEvent { + + public static void main(String[] args) throws Exception { + asyncCreateEvent(); + } + + public static void asyncCreateEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + CreateEventRequest request = + CreateEventRequest.newBuilder() + .setParent(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setEvent(Event.newBuilder().build()) + .setEventId("eventId-1376502443") + .setRequestId("requestId693933066") + .build(); + ApiFuture future = livestreamServiceClient.createEventCallable().futureCall(request); + // Do something. + Event response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createevent_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEvent.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEvent.java new file mode 100644 index 000000000000..1bc2d879086e --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createevent_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.CreateEventRequest; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncCreateEvent { + + public static void main(String[] args) throws Exception { + syncCreateEvent(); + } + + public static void syncCreateEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + CreateEventRequest request = + CreateEventRequest.newBuilder() + .setParent(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setEvent(Event.newBuilder().build()) + .setEventId("eventId-1376502443") + .setRequestId("requestId693933066") + .build(); + Event response = livestreamServiceClient.createEvent(request); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createevent_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEventChannelnameEventString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEventChannelnameEventString.java new file mode 100644 index 000000000000..6d3dec95648a --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEventChannelnameEventString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createevent_channelnameeventstring_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncCreateEventChannelnameEventString { + + public static void main(String[] args) throws Exception { + syncCreateEventChannelnameEventString(); + } + + public static void syncCreateEventChannelnameEventString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ChannelName parent = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + Event event = Event.newBuilder().build(); + String eventId = "eventId-1376502443"; + Event response = livestreamServiceClient.createEvent(parent, event, eventId); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createevent_channelnameeventstring_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEventStringEventString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEventStringEventString.java new file mode 100644 index 000000000000..ef55aaeef0ae --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createevent/SyncCreateEventStringEventString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createevent_stringeventstring_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncCreateEventStringEventString { + + public static void main(String[] args) throws Exception { + syncCreateEventStringEventString(); + } + + public static void syncCreateEventStringEventString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String parent = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString(); + Event event = Event.newBuilder().build(); + String eventId = "eventId-1376502443"; + Event response = livestreamServiceClient.createEvent(parent, event, eventId); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createevent_stringeventstring_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/AsyncCreateInput.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/AsyncCreateInput.java new file mode 100644 index 000000000000..3d1db0c2d265 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/AsyncCreateInput.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createinput_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.CreateInputRequest; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateInput { + + public static void main(String[] args) throws Exception { + asyncCreateInput(); + } + + public static void asyncCreateInput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + CreateInputRequest request = + CreateInputRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInput(Input.newBuilder().build()) + .setInputId("inputId1954846341") + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + livestreamServiceClient.createInputCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createinput_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/AsyncCreateInputLRO.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/AsyncCreateInputLRO.java new file mode 100644 index 000000000000..57d2f15581b6 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/AsyncCreateInputLRO.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createinput_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.video.livestream.v1.CreateInputRequest; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; +import com.google.cloud.video.livestream.v1.OperationMetadata; + +public class AsyncCreateInputLRO { + + public static void main(String[] args) throws Exception { + asyncCreateInputLRO(); + } + + public static void asyncCreateInputLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + CreateInputRequest request = + CreateInputRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInput(Input.newBuilder().build()) + .setInputId("inputId1954846341") + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + livestreamServiceClient.createInputOperationCallable().futureCall(request); + // Do something. + Input response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createinput_lro_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInput.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInput.java new file mode 100644 index 000000000000..7980ce6d0ac5 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInput.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createinput_sync] +import com.google.cloud.video.livestream.v1.CreateInputRequest; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncCreateInput { + + public static void main(String[] args) throws Exception { + syncCreateInput(); + } + + public static void syncCreateInput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + CreateInputRequest request = + CreateInputRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInput(Input.newBuilder().build()) + .setInputId("inputId1954846341") + .setRequestId("requestId693933066") + .build(); + Input response = livestreamServiceClient.createInputAsync(request).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createinput_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInputLocationnameInputString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInputLocationnameInputString.java new file mode 100644 index 000000000000..b1c38f1e6ef0 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInputLocationnameInputString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createinput_locationnameinputstring_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncCreateInputLocationnameInputString { + + public static void main(String[] args) throws Exception { + syncCreateInputLocationnameInputString(); + } + + public static void syncCreateInputLocationnameInputString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Input input = Input.newBuilder().build(); + String inputId = "inputId1954846341"; + Input response = livestreamServiceClient.createInputAsync(parent, input, inputId).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createinput_locationnameinputstring_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInputStringInputString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInputStringInputString.java new file mode 100644 index 000000000000..089b9945dfe5 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/createinput/SyncCreateInputStringInputString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_createinput_stringinputstring_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncCreateInputStringInputString { + + public static void main(String[] args) throws Exception { + syncCreateInputStringInputString(); + } + + public static void syncCreateInputStringInputString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Input input = Input.newBuilder().build(); + String inputId = "inputId1954846341"; + Input response = livestreamServiceClient.createInputAsync(parent, input, inputId).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_createinput_stringinputstring_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/AsyncDeleteChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/AsyncDeleteChannel.java new file mode 100644 index 000000000000..25feb28f84d0 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/AsyncDeleteChannel.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deletechannel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.DeleteChannelRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteChannel { + + public static void main(String[] args) throws Exception { + asyncDeleteChannel(); + } + + public static void asyncDeleteChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + DeleteChannelRequest request = + DeleteChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + ApiFuture future = + livestreamServiceClient.deleteChannelCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deletechannel_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/AsyncDeleteChannelLRO.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/AsyncDeleteChannelLRO.java new file mode 100644 index 000000000000..79d1283cd6c8 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/AsyncDeleteChannelLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deletechannel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.DeleteChannelRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteChannelLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteChannelLRO(); + } + + public static void asyncDeleteChannelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + DeleteChannelRequest request = + DeleteChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + OperationFuture future = + livestreamServiceClient.deleteChannelOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deletechannel_lro_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannel.java new file mode 100644 index 000000000000..3baa3e8301f8 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deletechannel_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.DeleteChannelRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteChannel { + + public static void main(String[] args) throws Exception { + syncDeleteChannel(); + } + + public static void syncDeleteChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + DeleteChannelRequest request = + DeleteChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .setForce(true) + .build(); + livestreamServiceClient.deleteChannelAsync(request).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deletechannel_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannelChannelname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannelChannelname.java new file mode 100644 index 000000000000..321a56a52fe1 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannelChannelname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deletechannel_channelname_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteChannelChannelname { + + public static void main(String[] args) throws Exception { + syncDeleteChannelChannelname(); + } + + public static void syncDeleteChannelChannelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + livestreamServiceClient.deleteChannelAsync(name).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deletechannel_channelname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannelString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannelString.java new file mode 100644 index 000000000000..6719746c2882 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deletechannel/SyncDeleteChannelString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deletechannel_string_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteChannelString { + + public static void main(String[] args) throws Exception { + syncDeleteChannelString(); + } + + public static void syncDeleteChannelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString(); + livestreamServiceClient.deleteChannelAsync(name).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deletechannel_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/AsyncDeleteEvent.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/AsyncDeleteEvent.java new file mode 100644 index 000000000000..8928b3c26a82 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/AsyncDeleteEvent.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.DeleteEventRequest; +import com.google.cloud.video.livestream.v1.EventName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteEvent { + + public static void main(String[] args) throws Exception { + asyncDeleteEvent(); + } + + public static void asyncDeleteEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + DeleteEventRequest request = + DeleteEventRequest.newBuilder() + .setName(EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = livestreamServiceClient.deleteEventCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteevent_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEvent.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEvent.java new file mode 100644 index 000000000000..869ad14ab069 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEvent.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteevent_sync] +import com.google.cloud.video.livestream.v1.DeleteEventRequest; +import com.google.cloud.video.livestream.v1.EventName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteEvent { + + public static void main(String[] args) throws Exception { + syncDeleteEvent(); + } + + public static void syncDeleteEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + DeleteEventRequest request = + DeleteEventRequest.newBuilder() + .setName(EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString()) + .setRequestId("requestId693933066") + .build(); + livestreamServiceClient.deleteEvent(request); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteevent_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEventEventname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEventEventname.java new file mode 100644 index 000000000000..d96d491f27b7 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEventEventname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteevent_eventname_sync] +import com.google.cloud.video.livestream.v1.EventName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteEventEventname { + + public static void main(String[] args) throws Exception { + syncDeleteEventEventname(); + } + + public static void syncDeleteEventEventname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + EventName name = EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]"); + livestreamServiceClient.deleteEvent(name); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteevent_eventname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEventString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEventString.java new file mode 100644 index 000000000000..675aeed2bb13 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteevent/SyncDeleteEventString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteevent_string_sync] +import com.google.cloud.video.livestream.v1.EventName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteEventString { + + public static void main(String[] args) throws Exception { + syncDeleteEventString(); + } + + public static void syncDeleteEventString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String name = EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString(); + livestreamServiceClient.deleteEvent(name); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteevent_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/AsyncDeleteInput.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/AsyncDeleteInput.java new file mode 100644 index 000000000000..28a14c82b103 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/AsyncDeleteInput.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteinput_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.DeleteInputRequest; +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteInput { + + public static void main(String[] args) throws Exception { + asyncDeleteInput(); + } + + public static void asyncDeleteInput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + DeleteInputRequest request = + DeleteInputRequest.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + livestreamServiceClient.deleteInputCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteinput_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/AsyncDeleteInputLRO.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/AsyncDeleteInputLRO.java new file mode 100644 index 000000000000..2f3929582926 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/AsyncDeleteInputLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteinput_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.video.livestream.v1.DeleteInputRequest; +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteInputLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteInputLRO(); + } + + public static void asyncDeleteInputLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + DeleteInputRequest request = + DeleteInputRequest.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + livestreamServiceClient.deleteInputOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteinput_lro_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInput.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInput.java new file mode 100644 index 000000000000..34ff018c0b7c --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInput.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteinput_sync] +import com.google.cloud.video.livestream.v1.DeleteInputRequest; +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteInput { + + public static void main(String[] args) throws Exception { + syncDeleteInput(); + } + + public static void syncDeleteInput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + DeleteInputRequest request = + DeleteInputRequest.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .setRequestId("requestId693933066") + .build(); + livestreamServiceClient.deleteInputAsync(request).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteinput_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInputInputname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInputInputname.java new file mode 100644 index 000000000000..8e57c33245e4 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInputInputname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteinput_inputname_sync] +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteInputInputname { + + public static void main(String[] args) throws Exception { + syncDeleteInputInputname(); + } + + public static void syncDeleteInputInputname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + InputName name = InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]"); + livestreamServiceClient.deleteInputAsync(name).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteinput_inputname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInputString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInputString.java new file mode 100644 index 000000000000..6703950bc37d --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/deleteinput/SyncDeleteInputString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_deleteinput_string_sync] +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncDeleteInputString { + + public static void main(String[] args) throws Exception { + syncDeleteInputString(); + } + + public static void syncDeleteInputString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String name = InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString(); + livestreamServiceClient.deleteInputAsync(name).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_deleteinput_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/AsyncGetChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/AsyncGetChannel.java new file mode 100644 index 000000000000..5766d52d4bc3 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/AsyncGetChannel.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getchannel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.GetChannelRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class AsyncGetChannel { + + public static void main(String[] args) throws Exception { + asyncGetChannel(); + } + + public static void asyncGetChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + GetChannelRequest request = + GetChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .build(); + ApiFuture future = livestreamServiceClient.getChannelCallable().futureCall(request); + // Do something. + Channel response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getchannel_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannel.java new file mode 100644 index 000000000000..be7eb16c6166 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannel.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getchannel_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.GetChannelRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetChannel { + + public static void main(String[] args) throws Exception { + syncGetChannel(); + } + + public static void syncGetChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + GetChannelRequest request = + GetChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .build(); + Channel response = livestreamServiceClient.getChannel(request); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getchannel_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannelChannelname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannelChannelname.java new file mode 100644 index 000000000000..a95c15c4a340 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannelChannelname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getchannel_channelname_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetChannelChannelname { + + public static void main(String[] args) throws Exception { + syncGetChannelChannelname(); + } + + public static void syncGetChannelChannelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + Channel response = livestreamServiceClient.getChannel(name); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getchannel_channelname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannelString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannelString.java new file mode 100644 index 000000000000..cabf70905af6 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getchannel/SyncGetChannelString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getchannel_string_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetChannelString { + + public static void main(String[] args) throws Exception { + syncGetChannelString(); + } + + public static void syncGetChannelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString(); + Channel response = livestreamServiceClient.getChannel(name); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getchannel_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/AsyncGetEvent.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/AsyncGetEvent.java new file mode 100644 index 000000000000..76f22c9042ba --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/AsyncGetEvent.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getevent_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.EventName; +import com.google.cloud.video.livestream.v1.GetEventRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class AsyncGetEvent { + + public static void main(String[] args) throws Exception { + asyncGetEvent(); + } + + public static void asyncGetEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + GetEventRequest request = + GetEventRequest.newBuilder() + .setName(EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString()) + .build(); + ApiFuture future = livestreamServiceClient.getEventCallable().futureCall(request); + // Do something. + Event response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getevent_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEvent.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEvent.java new file mode 100644 index 000000000000..b223aaa7684f --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEvent.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getevent_sync] +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.EventName; +import com.google.cloud.video.livestream.v1.GetEventRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetEvent { + + public static void main(String[] args) throws Exception { + syncGetEvent(); + } + + public static void syncGetEvent() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + GetEventRequest request = + GetEventRequest.newBuilder() + .setName(EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString()) + .build(); + Event response = livestreamServiceClient.getEvent(request); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getevent_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEventEventname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEventEventname.java new file mode 100644 index 000000000000..528fcc3798fd --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEventEventname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getevent_eventname_sync] +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.EventName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetEventEventname { + + public static void main(String[] args) throws Exception { + syncGetEventEventname(); + } + + public static void syncGetEventEventname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + EventName name = EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]"); + Event response = livestreamServiceClient.getEvent(name); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getevent_eventname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEventString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEventString.java new file mode 100644 index 000000000000..2b3414233d5f --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getevent/SyncGetEventString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getevent_string_sync] +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.EventName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetEventString { + + public static void main(String[] args) throws Exception { + syncGetEventString(); + } + + public static void syncGetEventString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String name = EventName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]", "[EVENT]").toString(); + Event response = livestreamServiceClient.getEvent(name); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getevent_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/AsyncGetInput.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/AsyncGetInput.java new file mode 100644 index 000000000000..1e75f21a780d --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/AsyncGetInput.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getinput_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.GetInputRequest; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class AsyncGetInput { + + public static void main(String[] args) throws Exception { + asyncGetInput(); + } + + public static void asyncGetInput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + GetInputRequest request = + GetInputRequest.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .build(); + ApiFuture future = livestreamServiceClient.getInputCallable().futureCall(request); + // Do something. + Input response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getinput_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInput.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInput.java new file mode 100644 index 000000000000..5068adebab13 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInput.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getinput_sync] +import com.google.cloud.video.livestream.v1.GetInputRequest; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetInput { + + public static void main(String[] args) throws Exception { + syncGetInput(); + } + + public static void syncGetInput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + GetInputRequest request = + GetInputRequest.newBuilder() + .setName(InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString()) + .build(); + Input response = livestreamServiceClient.getInput(request); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getinput_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInputInputname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInputInputname.java new file mode 100644 index 000000000000..0de95a3c4e10 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInputInputname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getinput_inputname_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetInputInputname { + + public static void main(String[] args) throws Exception { + syncGetInputInputname(); + } + + public static void syncGetInputInputname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + InputName name = InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]"); + Input response = livestreamServiceClient.getInput(name); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getinput_inputname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInputString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInputString.java new file mode 100644 index 000000000000..b6be1e9d53e1 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/getinput/SyncGetInputString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_getinput_string_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.InputName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncGetInputString { + + public static void main(String[] args) throws Exception { + syncGetInputString(); + } + + public static void syncGetInputString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String name = InputName.of("[PROJECT]", "[LOCATION]", "[INPUT]").toString(); + Input response = livestreamServiceClient.getInput(name); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_getinput_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/AsyncListChannels.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/AsyncListChannels.java new file mode 100644 index 000000000000..e41d3fbe03cf --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/AsyncListChannels.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listchannels_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.ListChannelsRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class AsyncListChannels { + + public static void main(String[] args) throws Exception { + asyncListChannels(); + } + + public static void asyncListChannels() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListChannelsRequest request = + ListChannelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + livestreamServiceClient.listChannelsPagedCallable().futureCall(request); + // Do something. + for (Channel element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listchannels_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/AsyncListChannelsPaged.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/AsyncListChannelsPaged.java new file mode 100644 index 000000000000..d549792aa89b --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/AsyncListChannelsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listchannels_paged_async] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.ListChannelsRequest; +import com.google.cloud.video.livestream.v1.ListChannelsResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListChannelsPaged { + + public static void main(String[] args) throws Exception { + asyncListChannelsPaged(); + } + + public static void asyncListChannelsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListChannelsRequest request = + ListChannelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListChannelsResponse response = + livestreamServiceClient.listChannelsCallable().call(request); + for (Channel element : response.getChannelsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listchannels_paged_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannels.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannels.java new file mode 100644 index 000000000000..8186b6ad4c06 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannels.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listchannels_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.ListChannelsRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncListChannels { + + public static void main(String[] args) throws Exception { + syncListChannels(); + } + + public static void syncListChannels() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListChannelsRequest request = + ListChannelsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Channel element : livestreamServiceClient.listChannels(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listchannels_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannelsLocationname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannelsLocationname.java new file mode 100644 index 000000000000..73a96e6f6b33 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannelsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listchannels_locationname_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncListChannelsLocationname { + + public static void main(String[] args) throws Exception { + syncListChannelsLocationname(); + } + + public static void syncListChannelsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Channel element : livestreamServiceClient.listChannels(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listchannels_locationname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannelsString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannelsString.java new file mode 100644 index 000000000000..277672825681 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listchannels/SyncListChannelsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listchannels_string_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncListChannelsString { + + public static void main(String[] args) throws Exception { + syncListChannelsString(); + } + + public static void syncListChannelsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Channel element : livestreamServiceClient.listChannels(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listchannels_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/AsyncListEvents.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/AsyncListEvents.java new file mode 100644 index 000000000000..f0dbf57aead4 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/AsyncListEvents.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listevents_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.ListEventsRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class AsyncListEvents { + + public static void main(String[] args) throws Exception { + asyncListEvents(); + } + + public static void asyncListEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListEventsRequest request = + ListEventsRequest.newBuilder() + .setParent(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + livestreamServiceClient.listEventsPagedCallable().futureCall(request); + // Do something. + for (Event element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listevents_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/AsyncListEventsPaged.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/AsyncListEventsPaged.java new file mode 100644 index 000000000000..7cdf377f4d43 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/AsyncListEventsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listevents_paged_async] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.ListEventsRequest; +import com.google.cloud.video.livestream.v1.ListEventsResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.common.base.Strings; + +public class AsyncListEventsPaged { + + public static void main(String[] args) throws Exception { + asyncListEventsPaged(); + } + + public static void asyncListEventsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListEventsRequest request = + ListEventsRequest.newBuilder() + .setParent(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListEventsResponse response = livestreamServiceClient.listEventsCallable().call(request); + for (Event element : response.getEventsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listevents_paged_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEvents.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEvents.java new file mode 100644 index 000000000000..abef8ad93488 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEvents.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listevents_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.ListEventsRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncListEvents { + + public static void main(String[] args) throws Exception { + syncListEvents(); + } + + public static void syncListEvents() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListEventsRequest request = + ListEventsRequest.newBuilder() + .setParent(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Event element : livestreamServiceClient.listEvents(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listevents_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEventsChannelname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEventsChannelname.java new file mode 100644 index 000000000000..934c415898e1 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEventsChannelname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listevents_channelname_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncListEventsChannelname { + + public static void main(String[] args) throws Exception { + syncListEventsChannelname(); + } + + public static void syncListEventsChannelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ChannelName parent = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + for (Event element : livestreamServiceClient.listEvents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listevents_channelname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEventsString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEventsString.java new file mode 100644 index 000000000000..0c7c67de72dd --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listevents/SyncListEventsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listevents_string_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.Event; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncListEventsString { + + public static void main(String[] args) throws Exception { + syncListEventsString(); + } + + public static void syncListEventsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String parent = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString(); + for (Event element : livestreamServiceClient.listEvents(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listevents_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/AsyncListInputs.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/AsyncListInputs.java new file mode 100644 index 000000000000..dd8e3715c6be --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/AsyncListInputs.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listinputs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.ListInputsRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class AsyncListInputs { + + public static void main(String[] args) throws Exception { + asyncListInputs(); + } + + public static void asyncListInputs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListInputsRequest request = + ListInputsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + livestreamServiceClient.listInputsPagedCallable().futureCall(request); + // Do something. + for (Input element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listinputs_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/AsyncListInputsPaged.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/AsyncListInputsPaged.java new file mode 100644 index 000000000000..e7134171fd43 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/AsyncListInputsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listinputs_paged_async] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.ListInputsRequest; +import com.google.cloud.video.livestream.v1.ListInputsResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListInputsPaged { + + public static void main(String[] args) throws Exception { + asyncListInputsPaged(); + } + + public static void asyncListInputsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListInputsRequest request = + ListInputsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListInputsResponse response = livestreamServiceClient.listInputsCallable().call(request); + for (Input element : response.getInputsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listinputs_paged_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputs.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputs.java new file mode 100644 index 000000000000..66bcb4ec9b2b --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputs.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listinputs_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.ListInputsRequest; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncListInputs { + + public static void main(String[] args) throws Exception { + syncListInputs(); + } + + public static void syncListInputs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ListInputsRequest request = + ListInputsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Input element : livestreamServiceClient.listInputs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listinputs_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputsLocationname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputsLocationname.java new file mode 100644 index 000000000000..39410252635c --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputsLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listinputs_locationname_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncListInputsLocationname { + + public static void main(String[] args) throws Exception { + syncListInputsLocationname(); + } + + public static void syncListInputsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Input element : livestreamServiceClient.listInputs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listinputs_locationname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputsString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputsString.java new file mode 100644 index 000000000000..e7c2e4c3dd2e --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/listinputs/SyncListInputsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_listinputs_string_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.LocationName; + +public class SyncListInputsString { + + public static void main(String[] args) throws Exception { + syncListInputsString(); + } + + public static void syncListInputsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Input element : livestreamServiceClient.listInputs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_listinputs_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/AsyncStartChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/AsyncStartChannel.java new file mode 100644 index 000000000000..d5b47e31543d --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/AsyncStartChannel.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_startchannel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.StartChannelRequest; +import com.google.longrunning.Operation; + +public class AsyncStartChannel { + + public static void main(String[] args) throws Exception { + asyncStartChannel(); + } + + public static void asyncStartChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + StartChannelRequest request = + StartChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + livestreamServiceClient.startChannelCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_startchannel_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/AsyncStartChannelLRO.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/AsyncStartChannelLRO.java new file mode 100644 index 000000000000..dda238105409 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/AsyncStartChannelLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_startchannel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.OperationMetadata; +import com.google.cloud.video.livestream.v1.StartChannelRequest; + +public class AsyncStartChannelLRO { + + public static void main(String[] args) throws Exception { + asyncStartChannelLRO(); + } + + public static void asyncStartChannelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + StartChannelRequest request = + StartChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + livestreamServiceClient.startChannelOperationCallable().futureCall(request); + // Do something. + ChannelOperationResponse response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_startchannel_lro_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannel.java new file mode 100644 index 000000000000..579c5acfd9b9 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_startchannel_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.StartChannelRequest; + +public class SyncStartChannel { + + public static void main(String[] args) throws Exception { + syncStartChannel(); + } + + public static void syncStartChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + StartChannelRequest request = + StartChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .build(); + ChannelOperationResponse response = livestreamServiceClient.startChannelAsync(request).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_startchannel_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannelChannelname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannelChannelname.java new file mode 100644 index 000000000000..a427a6955558 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannelChannelname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_startchannel_channelname_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncStartChannelChannelname { + + public static void main(String[] args) throws Exception { + syncStartChannelChannelname(); + } + + public static void syncStartChannelChannelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + ChannelOperationResponse response = livestreamServiceClient.startChannelAsync(name).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_startchannel_channelname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannelString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannelString.java new file mode 100644 index 000000000000..b2bedb38c998 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/startchannel/SyncStartChannelString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_startchannel_string_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncStartChannelString { + + public static void main(String[] args) throws Exception { + syncStartChannelString(); + } + + public static void syncStartChannelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString(); + ChannelOperationResponse response = livestreamServiceClient.startChannelAsync(name).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_startchannel_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/AsyncStopChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/AsyncStopChannel.java new file mode 100644 index 000000000000..332b911c65d9 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/AsyncStopChannel.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_stopchannel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.StopChannelRequest; +import com.google.longrunning.Operation; + +public class AsyncStopChannel { + + public static void main(String[] args) throws Exception { + asyncStopChannel(); + } + + public static void asyncStopChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + StopChannelRequest request = + StopChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + livestreamServiceClient.stopChannelCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_stopchannel_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/AsyncStopChannelLRO.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/AsyncStopChannelLRO.java new file mode 100644 index 000000000000..da6186f62ad8 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/AsyncStopChannelLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_stopchannel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.OperationMetadata; +import com.google.cloud.video.livestream.v1.StopChannelRequest; + +public class AsyncStopChannelLRO { + + public static void main(String[] args) throws Exception { + asyncStopChannelLRO(); + } + + public static void asyncStopChannelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + StopChannelRequest request = + StopChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + livestreamServiceClient.stopChannelOperationCallable().futureCall(request); + // Do something. + ChannelOperationResponse response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_stopchannel_lro_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannel.java new file mode 100644 index 000000000000..ec9fd473d788 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_stopchannel_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.StopChannelRequest; + +public class SyncStopChannel { + + public static void main(String[] args) throws Exception { + syncStopChannel(); + } + + public static void syncStopChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + StopChannelRequest request = + StopChannelRequest.newBuilder() + .setName(ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString()) + .setRequestId("requestId693933066") + .build(); + ChannelOperationResponse response = livestreamServiceClient.stopChannelAsync(request).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_stopchannel_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannelChannelname.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannelChannelname.java new file mode 100644 index 000000000000..638874da69b6 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannelChannelname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_stopchannel_channelname_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncStopChannelChannelname { + + public static void main(String[] args) throws Exception { + syncStopChannelChannelname(); + } + + public static void syncStopChannelChannelname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + ChannelName name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]"); + ChannelOperationResponse response = livestreamServiceClient.stopChannelAsync(name).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_stopchannel_channelname_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannelString.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannelString.java new file mode 100644 index 000000000000..9a3880c37555 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/stopchannel/SyncStopChannelString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_stopchannel_string_sync] +import com.google.cloud.video.livestream.v1.ChannelName; +import com.google.cloud.video.livestream.v1.ChannelOperationResponse; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; + +public class SyncStopChannelString { + + public static void main(String[] args) throws Exception { + syncStopChannelString(); + } + + public static void syncStopChannelString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + String name = ChannelName.of("[PROJECT]", "[LOCATION]", "[CHANNEL]").toString(); + ChannelOperationResponse response = livestreamServiceClient.stopChannelAsync(name).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_stopchannel_string_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/AsyncUpdateChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/AsyncUpdateChannel.java new file mode 100644 index 000000000000..d49afcbb99b7 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/AsyncUpdateChannel.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_updatechannel_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.UpdateChannelRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateChannel { + + public static void main(String[] args) throws Exception { + asyncUpdateChannel(); + } + + public static void asyncUpdateChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + UpdateChannelRequest request = + UpdateChannelRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setChannel(Channel.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + livestreamServiceClient.updateChannelCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_updatechannel_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/AsyncUpdateChannelLRO.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/AsyncUpdateChannelLRO.java new file mode 100644 index 000000000000..b030208cb9d1 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/AsyncUpdateChannelLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_updatechannel_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.OperationMetadata; +import com.google.cloud.video.livestream.v1.UpdateChannelRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateChannelLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateChannelLRO(); + } + + public static void asyncUpdateChannelLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + UpdateChannelRequest request = + UpdateChannelRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setChannel(Channel.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + livestreamServiceClient.updateChannelOperationCallable().futureCall(request); + // Do something. + Channel response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_updatechannel_lro_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/SyncUpdateChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/SyncUpdateChannel.java new file mode 100644 index 000000000000..3ca411a79f6c --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/SyncUpdateChannel.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_updatechannel_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.UpdateChannelRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateChannel { + + public static void main(String[] args) throws Exception { + syncUpdateChannel(); + } + + public static void syncUpdateChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + UpdateChannelRequest request = + UpdateChannelRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setChannel(Channel.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + Channel response = livestreamServiceClient.updateChannelAsync(request).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_updatechannel_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/SyncUpdateChannelChannelFieldmask.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/SyncUpdateChannelChannelFieldmask.java new file mode 100644 index 000000000000..092a411d28ae --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updatechannel/SyncUpdateChannelChannelFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_updatechannel_channelfieldmask_sync] +import com.google.cloud.video.livestream.v1.Channel; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateChannelChannelFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateChannelChannelFieldmask(); + } + + public static void syncUpdateChannelChannelFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + Channel channel = Channel.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Channel response = livestreamServiceClient.updateChannelAsync(channel, updateMask).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_updatechannel_channelfieldmask_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/AsyncUpdateInput.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/AsyncUpdateInput.java new file mode 100644 index 000000000000..c4a06f4ef6d9 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/AsyncUpdateInput.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_updateinput_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.UpdateInputRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInput { + + public static void main(String[] args) throws Exception { + asyncUpdateInput(); + } + + public static void asyncUpdateInput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + UpdateInputRequest request = + UpdateInputRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInput(Input.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + ApiFuture future = + livestreamServiceClient.updateInputCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_updateinput_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/AsyncUpdateInputLRO.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/AsyncUpdateInputLRO.java new file mode 100644 index 000000000000..f2fda500bdfa --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/AsyncUpdateInputLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_updateinput_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.OperationMetadata; +import com.google.cloud.video.livestream.v1.UpdateInputRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInputLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateInputLRO(); + } + + public static void asyncUpdateInputLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + UpdateInputRequest request = + UpdateInputRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInput(Input.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + OperationFuture future = + livestreamServiceClient.updateInputOperationCallable().futureCall(request); + // Do something. + Input response = future.get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_updateinput_lro_async] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/SyncUpdateInput.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/SyncUpdateInput.java new file mode 100644 index 000000000000..8ce5b06dfab4 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/SyncUpdateInput.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_updateinput_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.cloud.video.livestream.v1.UpdateInputRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInput { + + public static void main(String[] args) throws Exception { + syncUpdateInput(); + } + + public static void syncUpdateInput() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + UpdateInputRequest request = + UpdateInputRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInput(Input.newBuilder().build()) + .setRequestId("requestId693933066") + .build(); + Input response = livestreamServiceClient.updateInputAsync(request).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_updateinput_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/SyncUpdateInputInputFieldmask.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/SyncUpdateInputInputFieldmask.java new file mode 100644 index 000000000000..92322e0ff693 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamserviceclient/updateinput/SyncUpdateInputInputFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamserviceclient_updateinput_inputfieldmask_sync] +import com.google.cloud.video.livestream.v1.Input; +import com.google.cloud.video.livestream.v1.LivestreamServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInputInputFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateInputInputFieldmask(); + } + + public static void syncUpdateInputInputFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (LivestreamServiceClient livestreamServiceClient = LivestreamServiceClient.create()) { + Input input = Input.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Input response = livestreamServiceClient.updateInputAsync(input, updateMask).get(); + } + } +} +// [END livestream_v1_generated_livestreamserviceclient_updateinput_inputfieldmask_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamservicesettings/getchannel/SyncGetChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamservicesettings/getchannel/SyncGetChannel.java new file mode 100644 index 000000000000..5da52c8861e7 --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/livestreamservicesettings/getchannel/SyncGetChannel.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.samples; + +// [START livestream_v1_generated_livestreamservicesettings_getchannel_sync] +import com.google.cloud.video.livestream.v1.LivestreamServiceSettings; +import java.time.Duration; + +public class SyncGetChannel { + + public static void main(String[] args) throws Exception { + syncGetChannel(); + } + + public static void syncGetChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + LivestreamServiceSettings.Builder livestreamServiceSettingsBuilder = + LivestreamServiceSettings.newBuilder(); + livestreamServiceSettingsBuilder + .getChannelSettings() + .setRetrySettings( + livestreamServiceSettingsBuilder + .getChannelSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + LivestreamServiceSettings livestreamServiceSettings = livestreamServiceSettingsBuilder.build(); + } +} +// [END livestream_v1_generated_livestreamservicesettings_getchannel_sync] diff --git a/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/stub/livestreamservicestubsettings/getchannel/SyncGetChannel.java b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/stub/livestreamservicestubsettings/getchannel/SyncGetChannel.java new file mode 100644 index 000000000000..b37bf7dc8b0e --- /dev/null +++ b/java-video-live-stream/samples/snippets/generated/com/google/cloud/video/livestream/v1/stub/livestreamservicestubsettings/getchannel/SyncGetChannel.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.video.livestream.v1.stub.samples; + +// [START livestream_v1_generated_livestreamservicestubsettings_getchannel_sync] +import com.google.cloud.video.livestream.v1.stub.LivestreamServiceStubSettings; +import java.time.Duration; + +public class SyncGetChannel { + + public static void main(String[] args) throws Exception { + syncGetChannel(); + } + + public static void syncGetChannel() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + LivestreamServiceStubSettings.Builder livestreamServiceSettingsBuilder = + LivestreamServiceStubSettings.newBuilder(); + livestreamServiceSettingsBuilder + .getChannelSettings() + .setRetrySettings( + livestreamServiceSettingsBuilder + .getChannelSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + LivestreamServiceStubSettings livestreamServiceSettings = + livestreamServiceSettingsBuilder.build(); + } +} +// [END livestream_v1_generated_livestreamservicestubsettings_getchannel_sync]