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