diff --git a/google-cloud-video-intelligence/pom.xml b/google-cloud-video-intelligence/pom.xml index f97600bbb..bd533f586 100644 --- a/google-cloud-video-intelligence/pom.xml +++ b/google-cloud-video-intelligence/pom.xml @@ -74,6 +74,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -112,12 +116,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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceClient.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceClient.java index 369c0fe41..81d6e2be3 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceClient.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceClient.java @@ -17,13 +17,13 @@ package com.google.cloud.videointelligence.v1; 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.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.videointelligence.v1.stub.VideoIntelligenceServiceStub; import com.google.cloud.videointelligence.v1.stub.VideoIntelligenceServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -99,13 +99,29 @@ * VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); * } * + *

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.
+ * VideoIntelligenceServiceSettings videoIntelligenceServiceSettings =
+ *     VideoIntelligenceServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * VideoIntelligenceServiceClient videoIntelligenceServiceClient =
+ *     VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class VideoIntelligenceServiceClient implements BackgroundResource { private final VideoIntelligenceServiceSettings settings; private final VideoIntelligenceServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of VideoIntelligenceServiceClient with default settings. */ public static final VideoIntelligenceServiceClient create() throws IOException { @@ -139,13 +155,17 @@ protected VideoIntelligenceServiceClient(VideoIntelligenceServiceSettings settin throws IOException { this.settings = settings; this.stub = ((VideoIntelligenceServiceStubSettings) 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 VideoIntelligenceServiceClient(VideoIntelligenceServiceStub 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 VideoIntelligenceServiceSettings getSettings() { @@ -160,10 +180,18 @@ public VideoIntelligenceServiceStub 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. /** * Performs asynchronous video annotation. Progress and results can be retrieved through the diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceSettings.java index 2538abed2..58f79e67e 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceSettings.java @@ -21,6 +21,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; @@ -110,11 +111,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return VideoIntelligenceServiceStubSettings.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 VideoIntelligenceServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return VideoIntelligenceServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return VideoIntelligenceServiceStubSettings.defaultTransportChannelProvider(); } @@ -124,11 +132,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return VideoIntelligenceServiceStubSettings.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); @@ -167,6 +181,11 @@ private static Builder createDefault() { return new Builder(VideoIntelligenceServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(VideoIntelligenceServiceStubSettings.newHttpJsonBuilder()); + } + public VideoIntelligenceServiceStubSettings.Builder getStubSettingsBuilder() { return ((VideoIntelligenceServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java new file mode 100644 index 000000000..5b38e47ad --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.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.videointelligence.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 VideoIntelligenceService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonVideoIntelligenceServiceCallableFactory + 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/HttpJsonVideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/HttpJsonVideoIntelligenceServiceStub.java new file mode 100644 index 000000000..fd46d7322 --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/HttpJsonVideoIntelligenceServiceStub.java @@ -0,0 +1,230 @@ +/* + * 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.videointelligence.v1.stub; + +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.videointelligence.v1.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1.AnnotateVideoResponse; +import com.google.longrunning.Operation; +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 VideoIntelligenceService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonVideoIntelligenceServiceStub extends VideoIntelligenceServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(AnnotateVideoProgress.getDescriptor()) + .add(AnnotateVideoResponse.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + annotateVideoMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.videointelligence.v1.VideoIntelligenceService/AnnotateVideo") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/videos:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AnnotateVideoRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable annotateVideoCallable; + private final OperationCallable< + AnnotateVideoRequest, AnnotateVideoResponse, AnnotateVideoProgress> + annotateVideoOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonVideoIntelligenceServiceStub create( + VideoIntelligenceServiceStubSettings settings) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonVideoIntelligenceServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonVideoIntelligenceServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonVideoIntelligenceServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings annotateVideoTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(annotateVideoMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.annotateVideoCallable = + callableFactory.createUnaryCallable( + annotateVideoTransportSettings, settings.annotateVideoSettings(), clientContext); + this.annotateVideoOperationCallable = + callableFactory.createOperationCallable( + annotateVideoTransportSettings, + settings.annotateVideoOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(annotateVideoMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable annotateVideoCallable() { + return annotateVideoCallable; + } + + @Override + public OperationCallable + annotateVideoOperationCallable() { + return annotateVideoOperationCallable; + } + + @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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/VideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/VideoIntelligenceServiceStub.java index 19321dbae..311ac98c8 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/VideoIntelligenceServiceStub.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/VideoIntelligenceServiceStub.java @@ -36,7 +36,11 @@ public abstract class VideoIntelligenceServiceStub 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/VideoIntelligenceServiceStubSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/VideoIntelligenceServiceStubSettings.java index ba7025c03..ea297375e 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/VideoIntelligenceServiceStubSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1/stub/VideoIntelligenceServiceStubSettings.java @@ -25,6 +25,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; @@ -113,6 +116,11 @@ public VideoIntelligenceServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcVideoIntelligenceServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonVideoIntelligenceServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -145,18 +153,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(VideoIntelligenceServiceStubSettings.class)) @@ -164,11 +179,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(VideoIntelligenceServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return VideoIntelligenceServiceStubSettings.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); @@ -265,6 +299,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 .annotateVideoSettings() diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceClient.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceClient.java index 2299ee3cd..1210b11b6 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceClient.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; 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.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.videointelligence.v1beta2.stub.VideoIntelligenceServiceStub; import com.google.cloud.videointelligence.v1beta2.stub.VideoIntelligenceServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -100,6 +100,21 @@ * VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); * } * + *

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.
+ * VideoIntelligenceServiceSettings videoIntelligenceServiceSettings =
+ *     VideoIntelligenceServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * VideoIntelligenceServiceClient videoIntelligenceServiceClient =
+ *     VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -107,7 +122,8 @@ public class VideoIntelligenceServiceClient implements BackgroundResource { private final VideoIntelligenceServiceSettings settings; private final VideoIntelligenceServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of VideoIntelligenceServiceClient with default settings. */ public static final VideoIntelligenceServiceClient create() throws IOException { @@ -141,13 +157,17 @@ protected VideoIntelligenceServiceClient(VideoIntelligenceServiceSettings settin throws IOException { this.settings = settings; this.stub = ((VideoIntelligenceServiceStubSettings) 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 VideoIntelligenceServiceClient(VideoIntelligenceServiceStub 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 VideoIntelligenceServiceSettings getSettings() { @@ -162,10 +182,18 @@ public VideoIntelligenceServiceStub 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. /** * Performs asynchronous video annotation. Progress and results can be retrieved through the diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceSettings.java index 825dcfee2..3e7eac72b 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceSettings.java @@ -21,6 +21,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; @@ -111,11 +112,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return VideoIntelligenceServiceStubSettings.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 VideoIntelligenceServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return VideoIntelligenceServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return VideoIntelligenceServiceStubSettings.defaultTransportChannelProvider(); } @@ -125,11 +133,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return VideoIntelligenceServiceStubSettings.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); @@ -168,6 +182,11 @@ private static Builder createDefault() { return new Builder(VideoIntelligenceServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(VideoIntelligenceServiceStubSettings.newHttpJsonBuilder()); + } + public VideoIntelligenceServiceStubSettings.Builder getStubSettingsBuilder() { return ((VideoIntelligenceServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java new file mode 100644 index 000000000..49d8c6aeb --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/HttpJsonVideoIntelligenceServiceCallableFactory.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.videointelligence.v1beta2.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 VideoIntelligenceService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVideoIntelligenceServiceCallableFactory + 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/HttpJsonVideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/HttpJsonVideoIntelligenceServiceStub.java new file mode 100644 index 000000000..e3e3fb67a --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/HttpJsonVideoIntelligenceServiceStub.java @@ -0,0 +1,230 @@ +/* + * 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.videointelligence.v1beta2.stub; + +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.videointelligence.v1beta2.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoResponse; +import com.google.longrunning.Operation; +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 VideoIntelligenceService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVideoIntelligenceServiceStub extends VideoIntelligenceServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(AnnotateVideoResponse.getDescriptor()) + .add(AnnotateVideoProgress.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + annotateVideoMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.videointelligence.v1beta2.VideoIntelligenceService/AnnotateVideo") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta2/videos:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AnnotateVideoRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable annotateVideoCallable; + private final OperationCallable< + AnnotateVideoRequest, AnnotateVideoResponse, AnnotateVideoProgress> + annotateVideoOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonVideoIntelligenceServiceStub create( + VideoIntelligenceServiceStubSettings settings) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonVideoIntelligenceServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonVideoIntelligenceServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonVideoIntelligenceServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings annotateVideoTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(annotateVideoMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.annotateVideoCallable = + callableFactory.createUnaryCallable( + annotateVideoTransportSettings, settings.annotateVideoSettings(), clientContext); + this.annotateVideoOperationCallable = + callableFactory.createOperationCallable( + annotateVideoTransportSettings, + settings.annotateVideoOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(annotateVideoMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable annotateVideoCallable() { + return annotateVideoCallable; + } + + @Override + public OperationCallable + annotateVideoOperationCallable() { + return annotateVideoOperationCallable; + } + + @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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/VideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/VideoIntelligenceServiceStub.java index 3f91dc33a..a2f82df71 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/VideoIntelligenceServiceStub.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/VideoIntelligenceServiceStub.java @@ -38,7 +38,11 @@ public abstract class VideoIntelligenceServiceStub 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/VideoIntelligenceServiceStubSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/VideoIntelligenceServiceStubSettings.java index 5ff0cdeaf..e1df10967 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/VideoIntelligenceServiceStubSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1beta2/stub/VideoIntelligenceServiceStubSettings.java @@ -25,6 +25,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; @@ -114,6 +117,11 @@ public VideoIntelligenceServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcVideoIntelligenceServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonVideoIntelligenceServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -146,18 +154,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(VideoIntelligenceServiceStubSettings.class)) @@ -165,11 +180,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(VideoIntelligenceServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return VideoIntelligenceServiceStubSettings.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); @@ -266,6 +300,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 .annotateVideoSettings() diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClient.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClient.java index 18fec39c5..501a5f6f0 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClient.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; 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.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.videointelligence.v1p1beta1.stub.VideoIntelligenceServiceStub; import com.google.cloud.videointelligence.v1p1beta1.stub.VideoIntelligenceServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -100,6 +100,21 @@ * VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); * } * + *

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.
+ * VideoIntelligenceServiceSettings videoIntelligenceServiceSettings =
+ *     VideoIntelligenceServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * VideoIntelligenceServiceClient videoIntelligenceServiceClient =
+ *     VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -107,7 +122,8 @@ public class VideoIntelligenceServiceClient implements BackgroundResource { private final VideoIntelligenceServiceSettings settings; private final VideoIntelligenceServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of VideoIntelligenceServiceClient with default settings. */ public static final VideoIntelligenceServiceClient create() throws IOException { @@ -141,13 +157,17 @@ protected VideoIntelligenceServiceClient(VideoIntelligenceServiceSettings settin throws IOException { this.settings = settings; this.stub = ((VideoIntelligenceServiceStubSettings) 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 VideoIntelligenceServiceClient(VideoIntelligenceServiceStub 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 VideoIntelligenceServiceSettings getSettings() { @@ -162,10 +182,18 @@ public VideoIntelligenceServiceStub 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. /** * Performs asynchronous video annotation. Progress and results can be retrieved through the diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceSettings.java index 18110309d..97b237b10 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceSettings.java @@ -21,6 +21,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; @@ -111,11 +112,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return VideoIntelligenceServiceStubSettings.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 VideoIntelligenceServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return VideoIntelligenceServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return VideoIntelligenceServiceStubSettings.defaultTransportChannelProvider(); } @@ -125,11 +133,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return VideoIntelligenceServiceStubSettings.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); @@ -168,6 +182,11 @@ private static Builder createDefault() { return new Builder(VideoIntelligenceServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(VideoIntelligenceServiceStubSettings.newHttpJsonBuilder()); + } + public VideoIntelligenceServiceStubSettings.Builder getStubSettingsBuilder() { return ((VideoIntelligenceServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java new file mode 100644 index 000000000..77bd0fd5e --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.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.videointelligence.v1p1beta1.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 VideoIntelligenceService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVideoIntelligenceServiceCallableFactory + 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/HttpJsonVideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/HttpJsonVideoIntelligenceServiceStub.java new file mode 100644 index 000000000..aa9e9d868 --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/HttpJsonVideoIntelligenceServiceStub.java @@ -0,0 +1,230 @@ +/* + * 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.videointelligence.v1p1beta1.stub; + +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.videointelligence.v1p1beta1.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoResponse; +import com.google.longrunning.Operation; +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 VideoIntelligenceService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVideoIntelligenceServiceStub extends VideoIntelligenceServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(AnnotateVideoResponse.getDescriptor()) + .add(AnnotateVideoProgress.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + annotateVideoMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.videointelligence.v1p1beta1.VideoIntelligenceService/AnnotateVideo") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p1beta1/videos:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AnnotateVideoRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable annotateVideoCallable; + private final OperationCallable< + AnnotateVideoRequest, AnnotateVideoResponse, AnnotateVideoProgress> + annotateVideoOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonVideoIntelligenceServiceStub create( + VideoIntelligenceServiceStubSettings settings) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonVideoIntelligenceServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonVideoIntelligenceServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonVideoIntelligenceServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings annotateVideoTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(annotateVideoMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.annotateVideoCallable = + callableFactory.createUnaryCallable( + annotateVideoTransportSettings, settings.annotateVideoSettings(), clientContext); + this.annotateVideoOperationCallable = + callableFactory.createOperationCallable( + annotateVideoTransportSettings, + settings.annotateVideoOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(annotateVideoMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable annotateVideoCallable() { + return annotateVideoCallable; + } + + @Override + public OperationCallable + annotateVideoOperationCallable() { + return annotateVideoOperationCallable; + } + + @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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStub.java index dc5a07376..5d6a82e1b 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStub.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStub.java @@ -38,7 +38,11 @@ public abstract class VideoIntelligenceServiceStub 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStubSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStubSettings.java index b9df391c6..8ccb5e583 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStubSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p1beta1/stub/VideoIntelligenceServiceStubSettings.java @@ -25,6 +25,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; @@ -114,6 +117,11 @@ public VideoIntelligenceServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcVideoIntelligenceServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonVideoIntelligenceServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -146,18 +154,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(VideoIntelligenceServiceStubSettings.class)) @@ -165,11 +180,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(VideoIntelligenceServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return VideoIntelligenceServiceStubSettings.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); @@ -266,6 +300,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 .annotateVideoSettings() diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceClient.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceClient.java index 4f7685711..10e3b3e14 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceClient.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; 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.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.videointelligence.v1p2beta1.stub.VideoIntelligenceServiceStub; import com.google.cloud.videointelligence.v1p2beta1.stub.VideoIntelligenceServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -100,6 +100,21 @@ * VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); * } * + *

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.
+ * VideoIntelligenceServiceSettings videoIntelligenceServiceSettings =
+ *     VideoIntelligenceServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * VideoIntelligenceServiceClient videoIntelligenceServiceClient =
+ *     VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -107,7 +122,8 @@ public class VideoIntelligenceServiceClient implements BackgroundResource { private final VideoIntelligenceServiceSettings settings; private final VideoIntelligenceServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of VideoIntelligenceServiceClient with default settings. */ public static final VideoIntelligenceServiceClient create() throws IOException { @@ -141,13 +157,17 @@ protected VideoIntelligenceServiceClient(VideoIntelligenceServiceSettings settin throws IOException { this.settings = settings; this.stub = ((VideoIntelligenceServiceStubSettings) 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 VideoIntelligenceServiceClient(VideoIntelligenceServiceStub 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 VideoIntelligenceServiceSettings getSettings() { @@ -162,10 +182,18 @@ public VideoIntelligenceServiceStub 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. /** * Performs asynchronous video annotation. Progress and results can be retrieved through the diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceSettings.java index 7e6cc6b33..765f744b9 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceSettings.java @@ -21,6 +21,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; @@ -111,11 +112,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return VideoIntelligenceServiceStubSettings.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 VideoIntelligenceServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return VideoIntelligenceServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return VideoIntelligenceServiceStubSettings.defaultTransportChannelProvider(); } @@ -125,11 +133,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return VideoIntelligenceServiceStubSettings.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); @@ -168,6 +182,11 @@ private static Builder createDefault() { return new Builder(VideoIntelligenceServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(VideoIntelligenceServiceStubSettings.newHttpJsonBuilder()); + } + public VideoIntelligenceServiceStubSettings.Builder getStubSettingsBuilder() { return ((VideoIntelligenceServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java new file mode 100644 index 000000000..9512eaf11 --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.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.videointelligence.v1p2beta1.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 VideoIntelligenceService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVideoIntelligenceServiceCallableFactory + 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/HttpJsonVideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/HttpJsonVideoIntelligenceServiceStub.java new file mode 100644 index 000000000..c690ebd11 --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/HttpJsonVideoIntelligenceServiceStub.java @@ -0,0 +1,230 @@ +/* + * 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.videointelligence.v1p2beta1.stub; + +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.videointelligence.v1p2beta1.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoResponse; +import com.google.longrunning.Operation; +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 VideoIntelligenceService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVideoIntelligenceServiceStub extends VideoIntelligenceServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(AnnotateVideoResponse.getDescriptor()) + .add(AnnotateVideoProgress.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + annotateVideoMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.videointelligence.v1p2beta1.VideoIntelligenceService/AnnotateVideo") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p2beta1/videos:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AnnotateVideoRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable annotateVideoCallable; + private final OperationCallable< + AnnotateVideoRequest, AnnotateVideoResponse, AnnotateVideoProgress> + annotateVideoOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonVideoIntelligenceServiceStub create( + VideoIntelligenceServiceStubSettings settings) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonVideoIntelligenceServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonVideoIntelligenceServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonVideoIntelligenceServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings annotateVideoTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(annotateVideoMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.annotateVideoCallable = + callableFactory.createUnaryCallable( + annotateVideoTransportSettings, settings.annotateVideoSettings(), clientContext); + this.annotateVideoOperationCallable = + callableFactory.createOperationCallable( + annotateVideoTransportSettings, + settings.annotateVideoOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(annotateVideoMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable annotateVideoCallable() { + return annotateVideoCallable; + } + + @Override + public OperationCallable + annotateVideoOperationCallable() { + return annotateVideoOperationCallable; + } + + @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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/VideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/VideoIntelligenceServiceStub.java index 85c6846c0..7aa02b3a6 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/VideoIntelligenceServiceStub.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/VideoIntelligenceServiceStub.java @@ -38,7 +38,11 @@ public abstract class VideoIntelligenceServiceStub 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/VideoIntelligenceServiceStubSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/VideoIntelligenceServiceStubSettings.java index 5f44c8666..0eea0109a 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/VideoIntelligenceServiceStubSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p2beta1/stub/VideoIntelligenceServiceStubSettings.java @@ -25,6 +25,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; @@ -114,6 +117,11 @@ public VideoIntelligenceServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcVideoIntelligenceServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonVideoIntelligenceServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -146,18 +154,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(VideoIntelligenceServiceStubSettings.class)) @@ -165,11 +180,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(VideoIntelligenceServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return VideoIntelligenceServiceStubSettings.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); @@ -266,6 +300,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 .annotateVideoSettings() diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceClient.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceClient.java index aff3ab87c..58525f685 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceClient.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceClient.java @@ -98,6 +98,22 @@ * StreamingVideoIntelligenceServiceClient.create(streamingVideoIntelligenceServiceSettings); * } * + *

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.
+ * StreamingVideoIntelligenceServiceSettings streamingVideoIntelligenceServiceSettings =
+ *     StreamingVideoIntelligenceServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             StreamingVideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder()
+ *                 .build())
+ *         .build();
+ * StreamingVideoIntelligenceServiceClient streamingVideoIntelligenceServiceClient =
+ *     StreamingVideoIntelligenceServiceClient.create(streamingVideoIntelligenceServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceSettings.java index 977058938..036b6091b 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceSettings.java @@ -21,6 +21,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; @@ -106,11 +107,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return StreamingVideoIntelligenceServiceStubSettings.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 StreamingVideoIntelligenceServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return StreamingVideoIntelligenceServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return StreamingVideoIntelligenceServiceStubSettings.defaultTransportChannelProvider(); } @@ -120,11 +128,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return StreamingVideoIntelligenceServiceStubSettings.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); @@ -163,6 +177,11 @@ private static Builder createDefault() { return new Builder(StreamingVideoIntelligenceServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(StreamingVideoIntelligenceServiceStubSettings.newHttpJsonBuilder()); + } + public StreamingVideoIntelligenceServiceStubSettings.Builder getStubSettingsBuilder() { return ((StreamingVideoIntelligenceServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceClient.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceClient.java index 26e68645e..49cec9781 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceClient.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceClient.java @@ -18,13 +18,13 @@ import com.google.api.core.BetaApi; 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.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; import com.google.cloud.videointelligence.v1p3beta1.stub.VideoIntelligenceServiceStub; import com.google.cloud.videointelligence.v1p3beta1.stub.VideoIntelligenceServiceStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -100,6 +100,21 @@ * VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); * } * + *

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.
+ * VideoIntelligenceServiceSettings videoIntelligenceServiceSettings =
+ *     VideoIntelligenceServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * VideoIntelligenceServiceClient videoIntelligenceServiceClient =
+ *     VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -107,7 +122,8 @@ public class VideoIntelligenceServiceClient implements BackgroundResource { private final VideoIntelligenceServiceSettings settings; private final VideoIntelligenceServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of VideoIntelligenceServiceClient with default settings. */ public static final VideoIntelligenceServiceClient create() throws IOException { @@ -141,13 +157,17 @@ protected VideoIntelligenceServiceClient(VideoIntelligenceServiceSettings settin throws IOException { this.settings = settings; this.stub = ((VideoIntelligenceServiceStubSettings) 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 VideoIntelligenceServiceClient(VideoIntelligenceServiceStub 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 VideoIntelligenceServiceSettings getSettings() { @@ -162,10 +182,18 @@ public VideoIntelligenceServiceStub 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. /** * Performs asynchronous video annotation. Progress and results can be retrieved through the diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceSettings.java index dcd6c626c..44b5e9440 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceSettings.java @@ -21,6 +21,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; @@ -111,11 +112,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return VideoIntelligenceServiceStubSettings.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 VideoIntelligenceServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return VideoIntelligenceServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return VideoIntelligenceServiceStubSettings.defaultTransportChannelProvider(); } @@ -125,11 +133,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return VideoIntelligenceServiceStubSettings.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); @@ -168,6 +182,11 @@ private static Builder createDefault() { return new Builder(VideoIntelligenceServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(VideoIntelligenceServiceStubSettings.newHttpJsonBuilder()); + } + public VideoIntelligenceServiceStubSettings.Builder getStubSettingsBuilder() { return ((VideoIntelligenceServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonStreamingVideoIntelligenceServiceCallableFactory.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonStreamingVideoIntelligenceServiceCallableFactory.java new file mode 100644 index 000000000..b20333714 --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonStreamingVideoIntelligenceServiceCallableFactory.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.videointelligence.v1p3beta1.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 StreamingVideoIntelligenceService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonStreamingVideoIntelligenceServiceCallableFactory + 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonStreamingVideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonStreamingVideoIntelligenceServiceStub.java new file mode 100644 index 000000000..b27378661 --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonStreamingVideoIntelligenceServiceStub.java @@ -0,0 +1,136 @@ +/* + * 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.videointelligence.v1p3beta1.stub; + +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.HttpJsonStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the StreamingVideoIntelligenceService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonStreamingVideoIntelligenceServiceStub + extends StreamingVideoIntelligenceServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonStreamingVideoIntelligenceServiceStub create( + StreamingVideoIntelligenceServiceStubSettings settings) throws IOException { + return new HttpJsonStreamingVideoIntelligenceServiceStub( + settings, ClientContext.create(settings)); + } + + public static final HttpJsonStreamingVideoIntelligenceServiceStub create( + ClientContext clientContext) throws IOException { + return new HttpJsonStreamingVideoIntelligenceServiceStub( + StreamingVideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonStreamingVideoIntelligenceServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonStreamingVideoIntelligenceServiceStub( + StreamingVideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonStreamingVideoIntelligenceServiceStub, 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 HttpJsonStreamingVideoIntelligenceServiceStub( + StreamingVideoIntelligenceServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonStreamingVideoIntelligenceServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonStreamingVideoIntelligenceServiceStub, 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 HttpJsonStreamingVideoIntelligenceServiceStub( + StreamingVideoIntelligenceServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + return methodDescriptors; + } + + @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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.java new file mode 100644 index 000000000..c55939040 --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonVideoIntelligenceServiceCallableFactory.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.videointelligence.v1p3beta1.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 VideoIntelligenceService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVideoIntelligenceServiceCallableFactory + 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonVideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonVideoIntelligenceServiceStub.java new file mode 100644 index 000000000..6bf6af456 --- /dev/null +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/HttpJsonVideoIntelligenceServiceStub.java @@ -0,0 +1,230 @@ +/* + * 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.videointelligence.v1p3beta1.stub; + +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.videointelligence.v1p3beta1.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoResponse; +import com.google.longrunning.Operation; +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 VideoIntelligenceService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonVideoIntelligenceServiceStub extends VideoIntelligenceServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(AnnotateVideoResponse.getDescriptor()) + .add(AnnotateVideoProgress.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + annotateVideoMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.videointelligence.v1p3beta1.VideoIntelligenceService/AnnotateVideo") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1p3beta1/videos:annotate", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("*", request.toBuilder().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (AnnotateVideoRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable annotateVideoCallable; + private final OperationCallable< + AnnotateVideoRequest, AnnotateVideoResponse, AnnotateVideoProgress> + annotateVideoOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonVideoIntelligenceServiceStub create( + VideoIntelligenceServiceStubSettings settings) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonVideoIntelligenceServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonVideoIntelligenceServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonVideoIntelligenceServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonVideoIntelligenceServiceStub, 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 HttpJsonVideoIntelligenceServiceStub( + VideoIntelligenceServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings annotateVideoTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(annotateVideoMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.annotateVideoCallable = + callableFactory.createUnaryCallable( + annotateVideoTransportSettings, settings.annotateVideoSettings(), clientContext); + this.annotateVideoOperationCallable = + callableFactory.createOperationCallable( + annotateVideoTransportSettings, + settings.annotateVideoOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(annotateVideoMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable annotateVideoCallable() { + return annotateVideoCallable; + } + + @Override + public OperationCallable + annotateVideoOperationCallable() { + return annotateVideoOperationCallable; + } + + @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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/StreamingVideoIntelligenceServiceStubSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/StreamingVideoIntelligenceServiceStubSettings.java index 69861f135..72f3a93b4 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/StreamingVideoIntelligenceServiceStubSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/StreamingVideoIntelligenceServiceStubSettings.java @@ -24,6 +24,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +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.retrying.RetrySettings; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; @@ -103,6 +106,11 @@ public StreamingVideoIntelligenceServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcStreamingVideoIntelligenceServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonStreamingVideoIntelligenceServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -135,18 +143,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", @@ -155,11 +170,32 @@ 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(StreamingVideoIntelligenceServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return StreamingVideoIntelligenceServiceStubSettings + .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); @@ -251,6 +287,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) { return builder; } diff --git a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/VideoIntelligenceServiceStub.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/VideoIntelligenceServiceStub.java index 1596d9490..cab498c0e 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/VideoIntelligenceServiceStub.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/VideoIntelligenceServiceStub.java @@ -38,7 +38,11 @@ public abstract class VideoIntelligenceServiceStub 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/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/VideoIntelligenceServiceStubSettings.java b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/VideoIntelligenceServiceStubSettings.java index b6089445f..82dfac4a6 100644 --- a/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/VideoIntelligenceServiceStubSettings.java +++ b/google-cloud-video-intelligence/src/main/java/com/google/cloud/videointelligence/v1p3beta1/stub/VideoIntelligenceServiceStubSettings.java @@ -25,6 +25,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; @@ -114,6 +117,11 @@ public VideoIntelligenceServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcVideoIntelligenceServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonVideoIntelligenceServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -146,18 +154,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(VideoIntelligenceServiceStubSettings.class)) @@ -165,11 +180,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(VideoIntelligenceServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return VideoIntelligenceServiceStubSettings.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); @@ -266,6 +300,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 .annotateVideoSettings() diff --git a/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceClientHttpJsonTest.java b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceClientHttpJsonTest.java new file mode 100644 index 000000000..ce3ec37a8 --- /dev/null +++ b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1/VideoIntelligenceServiceClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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.videointelligence.v1; + +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.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.videointelligence.v1.stub.HttpJsonVideoIntelligenceServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +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 VideoIntelligenceServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static VideoIntelligenceServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonVideoIntelligenceServiceStub.getMethodDescriptors(), + VideoIntelligenceServiceSettings.getDefaultEndpoint()); + VideoIntelligenceServiceSettings settings = + VideoIntelligenceServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = VideoIntelligenceServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void annotateVideoTest() throws Exception { + AnnotateVideoResponse expectedResponse = + AnnotateVideoResponse.newBuilder() + .addAllAnnotationResults(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("annotateVideoTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + + AnnotateVideoResponse actualResponse = client.annotateVideoAsync(inputUri, features).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 annotateVideoExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + client.annotateVideoAsync(inputUri, features).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceClientHttpJsonTest.java b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceClientHttpJsonTest.java new file mode 100644 index 000000000..3290aea16 --- /dev/null +++ b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1beta2/VideoIntelligenceServiceClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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.videointelligence.v1beta2; + +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.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.videointelligence.v1beta2.stub.HttpJsonVideoIntelligenceServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +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 VideoIntelligenceServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static VideoIntelligenceServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonVideoIntelligenceServiceStub.getMethodDescriptors(), + VideoIntelligenceServiceSettings.getDefaultEndpoint()); + VideoIntelligenceServiceSettings settings = + VideoIntelligenceServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = VideoIntelligenceServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void annotateVideoTest() throws Exception { + AnnotateVideoResponse expectedResponse = + AnnotateVideoResponse.newBuilder() + .addAllAnnotationResults(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("annotateVideoTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + + AnnotateVideoResponse actualResponse = client.annotateVideoAsync(inputUri, features).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 annotateVideoExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + client.annotateVideoAsync(inputUri, features).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClientHttpJsonTest.java b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClientHttpJsonTest.java new file mode 100644 index 000000000..b3b750a70 --- /dev/null +++ b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p1beta1/VideoIntelligenceServiceClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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.videointelligence.v1p1beta1; + +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.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.videointelligence.v1p1beta1.stub.HttpJsonVideoIntelligenceServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +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 VideoIntelligenceServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static VideoIntelligenceServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonVideoIntelligenceServiceStub.getMethodDescriptors(), + VideoIntelligenceServiceSettings.getDefaultEndpoint()); + VideoIntelligenceServiceSettings settings = + VideoIntelligenceServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = VideoIntelligenceServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void annotateVideoTest() throws Exception { + AnnotateVideoResponse expectedResponse = + AnnotateVideoResponse.newBuilder() + .addAllAnnotationResults(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("annotateVideoTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + + AnnotateVideoResponse actualResponse = client.annotateVideoAsync(inputUri, features).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 annotateVideoExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + client.annotateVideoAsync(inputUri, features).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceClientHttpJsonTest.java b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceClientHttpJsonTest.java new file mode 100644 index 000000000..ef612f603 --- /dev/null +++ b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p2beta1/VideoIntelligenceServiceClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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.videointelligence.v1p2beta1; + +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.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.videointelligence.v1p2beta1.stub.HttpJsonVideoIntelligenceServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +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 VideoIntelligenceServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static VideoIntelligenceServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonVideoIntelligenceServiceStub.getMethodDescriptors(), + VideoIntelligenceServiceSettings.getDefaultEndpoint()); + VideoIntelligenceServiceSettings settings = + VideoIntelligenceServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = VideoIntelligenceServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void annotateVideoTest() throws Exception { + AnnotateVideoResponse expectedResponse = + AnnotateVideoResponse.newBuilder() + .addAllAnnotationResults(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("annotateVideoTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + + AnnotateVideoResponse actualResponse = client.annotateVideoAsync(inputUri, features).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 annotateVideoExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + client.annotateVideoAsync(inputUri, features).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceClientHttpJsonTest.java b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceClientHttpJsonTest.java new file mode 100644 index 000000000..693271857 --- /dev/null +++ b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p3beta1/StreamingVideoIntelligenceServiceClientHttpJsonTest.java @@ -0,0 +1,70 @@ +/* + * 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.videointelligence.v1p3beta1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.cloud.videointelligence.v1p3beta1.stub.HttpJsonStreamingVideoIntelligenceServiceStub; +import java.io.IOException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class StreamingVideoIntelligenceServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static StreamingVideoIntelligenceServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonStreamingVideoIntelligenceServiceStub.getMethodDescriptors(), + StreamingVideoIntelligenceServiceSettings.getDefaultEndpoint()); + StreamingVideoIntelligenceServiceSettings settings = + StreamingVideoIntelligenceServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + StreamingVideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = StreamingVideoIntelligenceServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void streamingAnnotateVideoUnsupportedMethodTest() throws Exception { + // The streamingAnnotateVideo() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } +} diff --git a/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceClientHttpJsonTest.java b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceClientHttpJsonTest.java new file mode 100644 index 000000000..f6529d015 --- /dev/null +++ b/google-cloud-video-intelligence/src/test/java/com/google/cloud/videointelligence/v1p3beta1/VideoIntelligenceServiceClientHttpJsonTest.java @@ -0,0 +1,127 @@ +/* + * 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.videointelligence.v1p3beta1; + +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.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.videointelligence.v1p3beta1.stub.HttpJsonVideoIntelligenceServiceStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import java.io.IOException; +import java.util.ArrayList; +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 VideoIntelligenceServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static VideoIntelligenceServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonVideoIntelligenceServiceStub.getMethodDescriptors(), + VideoIntelligenceServiceSettings.getDefaultEndpoint()); + VideoIntelligenceServiceSettings settings = + VideoIntelligenceServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = VideoIntelligenceServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void annotateVideoTest() throws Exception { + AnnotateVideoResponse expectedResponse = + AnnotateVideoResponse.newBuilder() + .addAllAnnotationResults(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("annotateVideoTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + + AnnotateVideoResponse actualResponse = client.annotateVideoAsync(inputUri, features).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 annotateVideoExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + client.annotateVideoAsync(inputUri, features).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..8c8d9a4de --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1.stub.samples; + +// [START videointelligence_v1_generated_videointelligenceservicestubsettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1.stub.VideoIntelligenceServiceStubSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceStubSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceStubSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceStubSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END videointelligence_v1_generated_videointelligenceservicestubsettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java new file mode 100644 index 000000000..e4cdf0bb0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java @@ -0,0 +1,56 @@ +/* + * 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.videointelligence.v1.samples; + +// [START videointelligence_v1_generated_videointelligenceserviceclient_annotatevideo_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.videointelligence.v1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1.Feature; +import com.google.cloud.videointelligence.v1.VideoContext; +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideo(); + } + + public static void asyncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + ApiFuture future = + videoIntelligenceServiceClient.annotateVideoCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END videointelligence_v1_generated_videointelligenceserviceclient_annotatevideo_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java new file mode 100644 index 000000000..65f58d9f8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java @@ -0,0 +1,57 @@ +/* + * 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.videointelligence.v1.samples; + +// [START videointelligence_v1_generated_videointelligenceserviceclient_annotatevideo_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.videointelligence.v1.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1.Feature; +import com.google.cloud.videointelligence.v1.VideoContext; +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideoLRO { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideoLRO(); + } + + public static void asyncAnnotateVideoLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + OperationFuture future = + videoIntelligenceServiceClient.annotateVideoOperationCallable().futureCall(request); + // Do something. + AnnotateVideoResponse response = future.get(); + } + } +} +// [END videointelligence_v1_generated_videointelligenceserviceclient_annotatevideo_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..b9566eedb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1.samples; + +// [START videointelligence_v1_generated_videointelligenceserviceclient_annotatevideo_sync] +import com.google.cloud.videointelligence.v1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1.Feature; +import com.google.cloud.videointelligence.v1.VideoContext; +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(request).get(); + } + } +} +// [END videointelligence_v1_generated_videointelligenceserviceclient_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java new file mode 100644 index 000000000..65facc202 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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.videointelligence.v1.samples; + +// [START +// videointelligence_v1_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] +import com.google.cloud.videointelligence.v1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1.Feature; +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAnnotateVideoStringListfeature { + + public static void main(String[] args) throws Exception { + syncAnnotateVideoStringListfeature(); + } + + public static void syncAnnotateVideoStringListfeature() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(inputUri, features).get(); + } + } +} +// [END +// videointelligence_v1_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..724680f3a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.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.videointelligence.v1.samples; + +// [START +// videointelligence_v1_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..1490a6db8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.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.videointelligence.v1.samples; + +// [START +// videointelligence_v1_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceSettings; + +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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..9db516e9d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/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.videointelligence.v1.samples; + +// [START videointelligence_v1_generated_videointelligenceserviceclient_create_setendpoint_sync] +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END videointelligence_v1_generated_videointelligenceserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..30b9aa63e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1.samples; + +// [START videointelligence_v1_generated_videointelligenceservicesettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1.VideoIntelligenceServiceSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END videointelligence_v1_generated_videointelligenceservicesettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..ab4d64f59 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1beta2.stub.samples; + +// [START +// videointelligence_v1beta2_generated_videointelligenceservicestubsettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1beta2.stub.VideoIntelligenceServiceStubSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceStubSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceStubSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceStubSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END videointelligence_v1beta2_generated_videointelligenceservicestubsettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java new file mode 100644 index 000000000..065d030b9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java @@ -0,0 +1,56 @@ +/* + * 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.videointelligence.v1beta2.samples; + +// [START videointelligence_v1beta2_generated_videointelligenceserviceclient_annotatevideo_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1beta2.Feature; +import com.google.cloud.videointelligence.v1beta2.VideoContext; +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideo(); + } + + public static void asyncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + ApiFuture future = + videoIntelligenceServiceClient.annotateVideoCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END videointelligence_v1beta2_generated_videointelligenceserviceclient_annotatevideo_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java new file mode 100644 index 000000000..dbdc031b8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java @@ -0,0 +1,58 @@ +/* + * 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.videointelligence.v1beta2.samples; + +// [START +// videointelligence_v1beta2_generated_videointelligenceserviceclient_annotatevideo_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1beta2.Feature; +import com.google.cloud.videointelligence.v1beta2.VideoContext; +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideoLRO { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideoLRO(); + } + + public static void asyncAnnotateVideoLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + OperationFuture future = + videoIntelligenceServiceClient.annotateVideoOperationCallable().futureCall(request); + // Do something. + AnnotateVideoResponse response = future.get(); + } + } +} +// [END videointelligence_v1beta2_generated_videointelligenceserviceclient_annotatevideo_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..a8fe3d154 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1beta2.samples; + +// [START videointelligence_v1beta2_generated_videointelligenceserviceclient_annotatevideo_sync] +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1beta2.Feature; +import com.google.cloud.videointelligence.v1beta2.VideoContext; +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(request).get(); + } + } +} +// [END videointelligence_v1beta2_generated_videointelligenceserviceclient_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java new file mode 100644 index 000000000..5cb7e22d2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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.videointelligence.v1beta2.samples; + +// [START +// videointelligence_v1beta2_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] +import com.google.cloud.videointelligence.v1beta2.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1beta2.Feature; +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAnnotateVideoStringListfeature { + + public static void main(String[] args) throws Exception { + syncAnnotateVideoStringListfeature(); + } + + public static void syncAnnotateVideoStringListfeature() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(inputUri, features).get(); + } + } +} +// [END +// videointelligence_v1beta2_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..ceaee81f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.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.videointelligence.v1beta2.samples; + +// [START +// videointelligence_v1beta2_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1beta2.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1beta2_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..84bd52042 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.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.videointelligence.v1beta2.samples; + +// [START +// videointelligence_v1beta2_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceSettings; + +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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1beta2_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..42e9a82b7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetEndpoint.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.videointelligence.v1beta2.samples; + +// [START +// videointelligence_v1beta2_generated_videointelligenceserviceclient_create_setendpoint_sync] +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1beta2.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END videointelligence_v1beta2_generated_videointelligenceserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..801276110 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1beta2.samples; + +// [START videointelligence_v1beta2_generated_videointelligenceservicesettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1beta2.VideoIntelligenceServiceSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END videointelligence_v1beta2_generated_videointelligenceservicesettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..0e1339a98 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p1beta1.stub.samples; + +// [START +// videointelligence_v1p1beta1_generated_videointelligenceservicestubsettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p1beta1.stub.VideoIntelligenceServiceStubSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceStubSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceStubSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceStubSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END +// videointelligence_v1p1beta1_generated_videointelligenceservicestubsettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java new file mode 100644 index 000000000..8c224a2c2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java @@ -0,0 +1,56 @@ +/* + * 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.videointelligence.v1p1beta1.samples; + +// [START videointelligence_v1p1beta1_generated_videointelligenceserviceclient_annotatevideo_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p1beta1.Feature; +import com.google.cloud.videointelligence.v1p1beta1.VideoContext; +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideo(); + } + + public static void asyncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + ApiFuture future = + videoIntelligenceServiceClient.annotateVideoCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END videointelligence_v1p1beta1_generated_videointelligenceserviceclient_annotatevideo_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java new file mode 100644 index 000000000..f95fefb89 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java @@ -0,0 +1,59 @@ +/* + * 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.videointelligence.v1p1beta1.samples; + +// [START +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_annotatevideo_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p1beta1.Feature; +import com.google.cloud.videointelligence.v1p1beta1.VideoContext; +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideoLRO { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideoLRO(); + } + + public static void asyncAnnotateVideoLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + OperationFuture future = + videoIntelligenceServiceClient.annotateVideoOperationCallable().futureCall(request); + // Do something. + AnnotateVideoResponse response = future.get(); + } + } +} +// [END +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_annotatevideo_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..e9cf0faee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p1beta1.samples; + +// [START videointelligence_v1p1beta1_generated_videointelligenceserviceclient_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p1beta1.Feature; +import com.google.cloud.videointelligence.v1p1beta1.VideoContext; +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(request).get(); + } + } +} +// [END videointelligence_v1p1beta1_generated_videointelligenceserviceclient_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java new file mode 100644 index 000000000..c7d0f5af8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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.videointelligence.v1p1beta1.samples; + +// [START +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] +import com.google.cloud.videointelligence.v1p1beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p1beta1.Feature; +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAnnotateVideoStringListfeature { + + public static void main(String[] args) throws Exception { + syncAnnotateVideoStringListfeature(); + } + + public static void syncAnnotateVideoStringListfeature() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(inputUri, features).get(); + } + } +} +// [END +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..4088eafe7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.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.videointelligence.v1p1beta1.samples; + +// [START +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1p1beta1.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..68d9b64e4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.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.videointelligence.v1p1beta1.samples; + +// [START +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceSettings; + +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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..35a534c9f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.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.videointelligence.v1p1beta1.samples; + +// [START +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_create_setendpoint_sync] +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1p1beta1.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p1beta1_generated_videointelligenceserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..2abad3fce --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p1beta1.samples; + +// [START videointelligence_v1p1beta1_generated_videointelligenceservicesettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p1beta1.VideoIntelligenceServiceSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END videointelligence_v1p1beta1_generated_videointelligenceservicesettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..160b44c2b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p2beta1.stub.samples; + +// [START +// videointelligence_v1p2beta1_generated_videointelligenceservicestubsettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p2beta1.stub.VideoIntelligenceServiceStubSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceStubSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceStubSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceStubSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END +// videointelligence_v1p2beta1_generated_videointelligenceservicestubsettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java new file mode 100644 index 000000000..3fe41cdfc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java @@ -0,0 +1,56 @@ +/* + * 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.videointelligence.v1p2beta1.samples; + +// [START videointelligence_v1p2beta1_generated_videointelligenceserviceclient_annotatevideo_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p2beta1.Feature; +import com.google.cloud.videointelligence.v1p2beta1.VideoContext; +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideo(); + } + + public static void asyncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + ApiFuture future = + videoIntelligenceServiceClient.annotateVideoCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END videointelligence_v1p2beta1_generated_videointelligenceserviceclient_annotatevideo_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java new file mode 100644 index 000000000..7ddea1a28 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java @@ -0,0 +1,59 @@ +/* + * 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.videointelligence.v1p2beta1.samples; + +// [START +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_annotatevideo_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p2beta1.Feature; +import com.google.cloud.videointelligence.v1p2beta1.VideoContext; +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideoLRO { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideoLRO(); + } + + public static void asyncAnnotateVideoLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + OperationFuture future = + videoIntelligenceServiceClient.annotateVideoOperationCallable().futureCall(request); + // Do something. + AnnotateVideoResponse response = future.get(); + } + } +} +// [END +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_annotatevideo_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..981e87b55 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p2beta1.samples; + +// [START videointelligence_v1p2beta1_generated_videointelligenceserviceclient_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p2beta1.Feature; +import com.google.cloud.videointelligence.v1p2beta1.VideoContext; +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(request).get(); + } + } +} +// [END videointelligence_v1p2beta1_generated_videointelligenceserviceclient_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java new file mode 100644 index 000000000..efe6e536b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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.videointelligence.v1p2beta1.samples; + +// [START +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] +import com.google.cloud.videointelligence.v1p2beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p2beta1.Feature; +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAnnotateVideoStringListfeature { + + public static void main(String[] args) throws Exception { + syncAnnotateVideoStringListfeature(); + } + + public static void syncAnnotateVideoStringListfeature() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(inputUri, features).get(); + } + } +} +// [END +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..d99688f2d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.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.videointelligence.v1p2beta1.samples; + +// [START +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1p2beta1.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..44d437931 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.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.videointelligence.v1p2beta1.samples; + +// [START +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceSettings; + +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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..9c5d26317 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.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.videointelligence.v1p2beta1.samples; + +// [START +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_create_setendpoint_sync] +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1p2beta1.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p2beta1_generated_videointelligenceserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..656af07ff --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p2beta1.samples; + +// [START videointelligence_v1p2beta1_generated_videointelligenceservicesettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p2beta1.VideoIntelligenceServiceSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END videointelligence_v1p2beta1_generated_videointelligenceservicesettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..7d19294d4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_streamingvideointelligenceserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1p3beta1.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. + StreamingVideoIntelligenceServiceSettings streamingVideoIntelligenceServiceSettings = + StreamingVideoIntelligenceServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + StreamingVideoIntelligenceServiceClient streamingVideoIntelligenceServiceClient = + StreamingVideoIntelligenceServiceClient.create(streamingVideoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p3beta1_generated_streamingvideointelligenceserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..78e7f5ece --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_streamingvideointelligenceserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceSettings; + +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. + StreamingVideoIntelligenceServiceSettings streamingVideoIntelligenceServiceSettings = + StreamingVideoIntelligenceServiceSettings.newBuilder() + .setTransportChannelProvider( + StreamingVideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder() + .build()) + .build(); + StreamingVideoIntelligenceServiceClient streamingVideoIntelligenceServiceClient = + StreamingVideoIntelligenceServiceClient.create(streamingVideoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p3beta1_generated_streamingvideointelligenceserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..17abe6667 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetEndpoint.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_streamingvideointelligenceserviceclient_create_setendpoint_sync] +import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1p3beta1.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. + StreamingVideoIntelligenceServiceSettings streamingVideoIntelligenceServiceSettings = + StreamingVideoIntelligenceServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + StreamingVideoIntelligenceServiceClient streamingVideoIntelligenceServiceClient = + StreamingVideoIntelligenceServiceClient.create(streamingVideoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p3beta1_generated_streamingvideointelligenceserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/streamingannotatevideo/AsyncStreamingAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/streamingannotatevideo/AsyncStreamingAnnotateVideo.java new file mode 100644 index 000000000..ccc30e85a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/streamingannotatevideo/AsyncStreamingAnnotateVideo.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_streamingvideointelligenceserviceclient_streamingannotatevideo_async] +import com.google.api.gax.rpc.BidiStream; +import com.google.cloud.videointelligence.v1p3beta1.StreamingAnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p3beta1.StreamingAnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceClient; + +public class AsyncStreamingAnnotateVideo { + + public static void main(String[] args) throws Exception { + asyncStreamingAnnotateVideo(); + } + + public static void asyncStreamingAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (StreamingVideoIntelligenceServiceClient streamingVideoIntelligenceServiceClient = + StreamingVideoIntelligenceServiceClient.create()) { + BidiStream bidiStream = + streamingVideoIntelligenceServiceClient.streamingAnnotateVideoCallable().call(); + StreamingAnnotateVideoRequest request = StreamingAnnotateVideoRequest.newBuilder().build(); + bidiStream.send(request); + for (StreamingAnnotateVideoResponse response : bidiStream) { + // Do something when a response is received. + } + } + } +} +// [END +// videointelligence_v1p3beta1_generated_streamingvideointelligenceserviceclient_streamingannotatevideo_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceservicesettings/streamingannotatevideo/SyncStreamingAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceservicesettings/streamingannotatevideo/SyncStreamingAnnotateVideo.java new file mode 100644 index 000000000..8fac3c7ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceservicesettings/streamingannotatevideo/SyncStreamingAnnotateVideo.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_streamingvideointelligenceservicesettings_streamingannotatevideo_sync] +import com.google.cloud.videointelligence.v1p3beta1.StreamingVideoIntelligenceServiceSettings; +import java.time.Duration; + +public class SyncStreamingAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncStreamingAnnotateVideo(); + } + + public static void syncStreamingAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + StreamingVideoIntelligenceServiceSettings.Builder + streamingVideoIntelligenceServiceSettingsBuilder = + StreamingVideoIntelligenceServiceSettings.newBuilder(); + streamingVideoIntelligenceServiceSettingsBuilder + .streamingAnnotateVideoSettings() + .setRetrySettings( + streamingVideoIntelligenceServiceSettingsBuilder + .streamingAnnotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + StreamingVideoIntelligenceServiceSettings streamingVideoIntelligenceServiceSettings = + streamingVideoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END +// videointelligence_v1p3beta1_generated_streamingvideointelligenceservicesettings_streamingannotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/stub/streamingvideointelligenceservicestubsettings/streamingannotatevideo/SyncStreamingAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/stub/streamingvideointelligenceservicestubsettings/streamingannotatevideo/SyncStreamingAnnotateVideo.java new file mode 100644 index 000000000..5cd4e0ca3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/stub/streamingvideointelligenceservicestubsettings/streamingannotatevideo/SyncStreamingAnnotateVideo.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.videointelligence.v1p3beta1.stub.samples; + +// [START +// videointelligence_v1p3beta1_generated_streamingvideointelligenceservicestubsettings_streamingannotatevideo_sync] +import com.google.cloud.videointelligence.v1p3beta1.stub.StreamingVideoIntelligenceServiceStubSettings; +import java.time.Duration; + +public class SyncStreamingAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncStreamingAnnotateVideo(); + } + + public static void syncStreamingAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + StreamingVideoIntelligenceServiceStubSettings.Builder + streamingVideoIntelligenceServiceSettingsBuilder = + StreamingVideoIntelligenceServiceStubSettings.newBuilder(); + streamingVideoIntelligenceServiceSettingsBuilder + .streamingAnnotateVideoSettings() + .setRetrySettings( + streamingVideoIntelligenceServiceSettingsBuilder + .streamingAnnotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + StreamingVideoIntelligenceServiceStubSettings streamingVideoIntelligenceServiceSettings = + streamingVideoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END +// videointelligence_v1p3beta1_generated_streamingvideointelligenceservicestubsettings_streamingannotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..56075a6d0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/stub/videointelligenceservicestubsettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p3beta1.stub.samples; + +// [START +// videointelligence_v1p3beta1_generated_videointelligenceservicestubsettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p3beta1.stub.VideoIntelligenceServiceStubSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceStubSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceStubSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceStubSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END +// videointelligence_v1p3beta1_generated_videointelligenceservicestubsettings_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java new file mode 100644 index 000000000..2d10cd08b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideo.java @@ -0,0 +1,56 @@ +/* + * 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.videointelligence.v1p3beta1.samples; + +// [START videointelligence_v1p3beta1_generated_videointelligenceserviceclient_annotatevideo_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p3beta1.Feature; +import com.google.cloud.videointelligence.v1p3beta1.VideoContext; +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceClient; +import com.google.longrunning.Operation; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideo(); + } + + public static void asyncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + ApiFuture future = + videoIntelligenceServiceClient.annotateVideoCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END videointelligence_v1p3beta1_generated_videointelligenceserviceclient_annotatevideo_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java new file mode 100644 index 000000000..f40391fab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/AsyncAnnotateVideoLRO.java @@ -0,0 +1,59 @@ +/* + * 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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_annotatevideo_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoProgress; +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p3beta1.Feature; +import com.google.cloud.videointelligence.v1p3beta1.VideoContext; +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class AsyncAnnotateVideoLRO { + + public static void main(String[] args) throws Exception { + asyncAnnotateVideoLRO(); + } + + public static void asyncAnnotateVideoLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + OperationFuture future = + videoIntelligenceServiceClient.annotateVideoOperationCallable().futureCall(request); + // Do something. + AnnotateVideoResponse response = future.get(); + } + } +} +// [END +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_annotatevideo_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..91e2e4892 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p3beta1.samples; + +// [START videointelligence_v1p3beta1_generated_videointelligenceserviceclient_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoRequest; +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p3beta1.Feature; +import com.google.cloud.videointelligence.v1p3beta1.VideoContext; +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceClient; +import com.google.protobuf.ByteString; +import java.util.ArrayList; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + AnnotateVideoRequest request = + AnnotateVideoRequest.newBuilder() + .setInputUri("inputUri470706498") + .setInputContent(ByteString.EMPTY) + .addAllFeatures(new ArrayList()) + .setVideoContext(VideoContext.newBuilder().build()) + .setOutputUri("outputUri-2119300949") + .setLocationId("locationId1541836720") + .build(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(request).get(); + } + } +} +// [END videointelligence_v1p3beta1_generated_videointelligenceserviceclient_annotatevideo_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.java new file mode 100644 index 000000000..4024aab1d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] +import com.google.cloud.videointelligence.v1p3beta1.AnnotateVideoResponse; +import com.google.cloud.videointelligence.v1p3beta1.Feature; +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceClient; +import java.util.ArrayList; +import java.util.List; + +public class SyncAnnotateVideoStringListfeature { + + public static void main(String[] args) throws Exception { + syncAnnotateVideoStringListfeature(); + } + + public static void syncAnnotateVideoStringListfeature() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create()) { + String inputUri = "inputUri470706498"; + List features = new ArrayList<>(); + AnnotateVideoResponse response = + videoIntelligenceServiceClient.annotateVideoAsync(inputUri, features).get(); + } + } +} +// [END +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_annotatevideo_stringlistfeature_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000..e36036c09 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1p3beta1.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000..d8748bf2f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceSettings; + +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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder() + .setTransportChannelProvider( + VideoIntelligenceServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000..03819a397 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetEndpoint.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.videointelligence.v1p3beta1.samples; + +// [START +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_create_setendpoint_sync] +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceClient; +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceSettings; +import com.google.cloud.videointelligence.v1p3beta1.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. + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + VideoIntelligenceServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + VideoIntelligenceServiceClient videoIntelligenceServiceClient = + VideoIntelligenceServiceClient.create(videoIntelligenceServiceSettings); + } +} +// [END +// videointelligence_v1p3beta1_generated_videointelligenceserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.java new file mode 100644 index 000000000..d3c9c22fb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceservicesettings/annotatevideo/SyncAnnotateVideo.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.videointelligence.v1p3beta1.samples; + +// [START videointelligence_v1p3beta1_generated_videointelligenceservicesettings_annotatevideo_sync] +import com.google.cloud.videointelligence.v1p3beta1.VideoIntelligenceServiceSettings; +import java.time.Duration; + +public class SyncAnnotateVideo { + + public static void main(String[] args) throws Exception { + syncAnnotateVideo(); + } + + public static void syncAnnotateVideo() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + VideoIntelligenceServiceSettings.Builder videoIntelligenceServiceSettingsBuilder = + VideoIntelligenceServiceSettings.newBuilder(); + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .setRetrySettings( + videoIntelligenceServiceSettingsBuilder + .annotateVideoSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + VideoIntelligenceServiceSettings videoIntelligenceServiceSettings = + videoIntelligenceServiceSettingsBuilder.build(); + } +} +// [END videointelligence_v1p3beta1_generated_videointelligenceservicesettings_annotatevideo_sync]