diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index a79f06271..a454a61e8 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:2567a120ce90fadb6201999b87d649d9f67459de28815ad239bce9ebfaa18a74 -# created: 2022-05-19T15:12:45.278246753Z + digest: sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 +# created: 2022-06-29T23:17:33.110417661Z diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml index d723813c7..66edc7079 100644 --- a/.github/.OwlBot.yaml +++ b/.github/.OwlBot.yaml @@ -16,6 +16,7 @@ docker: image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest" deep-remove-regex: +- "/samples/snippets/generated" - "/grpc-google-.*/src" - "/proto-google-.*/src" - "/google-.*/src" @@ -30,3 +31,5 @@ deep-copy-regex: dest: "/owl-bot-staging/$1/grpc-google-cloud-video-intelligence-$1/src" - source: "/google/cloud/videointelligence/(v.*)/.*-java/gapic-google-.*/src" dest: "/owl-bot-staging/$1/google-cloud-video-intelligence/src" +- source: "/google/cloud/videointelligence/(v.*)/.*-java/samples/snippets/generated" + dest: "/owl-bot-staging/$1/samples/snippets/generated" diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 6f09d6956..dd5626f32 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -11,7 +11,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (8) - units (11) - 'Kokoro - Test: Integration' @@ -26,7 +25,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (7) - units (8) - units (11) diff --git a/.kokoro/common.sh b/.kokoro/common.sh index ace89f45a..f8f957af1 100644 --- a/.kokoro/common.sh +++ b/.kokoro/common.sh @@ -55,4 +55,6 @@ function retry_with_backoff { ## Helper functionss function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } function msg() { println "$*" >&2; } -function println() { printf '%s\n' "$(now) $*"; } \ No newline at end of file +function println() { printf '%s\n' "$(now) $*"; } + +## Helper comment to trigger updated repo dependency release \ No newline at end of file diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh index 77dc4e8f0..1dba8de10 100755 --- a/.kokoro/release/stage.sh +++ b/.kokoro/release/stage.sh @@ -32,6 +32,7 @@ retry_with_backoff 3 10 \ mvn clean deploy -B \ --settings ${MAVEN_SETTINGS_FILE} \ -DskipTests=true \ + -Dclirr.skip=true \ -DperformRelease=true \ -Dgpg.executable=gpg \ -Dgpg.passphrase=${GPG_PASSPHRASE} \ @@ -42,4 +43,4 @@ then mvn nexus-staging:release -B \ -DperformRelease=true \ --settings=settings.xml -fi \ No newline at end of file +fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 5082eae7b..000151df8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [2.2.0](https://github.com/googleapis/java-video-intelligence/compare/v2.1.0...v2.2.0) (2022-07-01) + + +### Features + +* Enable REST transport for most of Java and Go clients ([#920](https://github.com/googleapis/java-video-intelligence/issues/920)) ([808c131](https://github.com/googleapis/java-video-intelligence/commit/808c131cd11cdfeaa2a63073dad2977646cd30ef)) + + +### Bug Fixes + +* update gapic-generator-java with mock service generation fixes ([#922](https://github.com/googleapis/java-video-intelligence/issues/922)) ([b1d854d](https://github.com/googleapis/java-video-intelligence/commit/b1d854d364902a3b30ec204ff9909ad04af15b16)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-core to v2.8.0 ([#918](https://github.com/googleapis/java-video-intelligence/issues/918)) ([4b84302](https://github.com/googleapis/java-video-intelligence/commit/4b84302d2a90a6f9b4f944e3955d3f4a8174a969)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#919](https://github.com/googleapis/java-video-intelligence/issues/919)) ([6edfbd3](https://github.com/googleapis/java-video-intelligence/commit/6edfbd34a3931c608c2b51deb00381c963202ac8)) +* update dependency com.google.cloud:google-cloud-storage to v2.7.0 ([#912](https://github.com/googleapis/java-video-intelligence/issues/912)) ([5d4ed30](https://github.com/googleapis/java-video-intelligence/commit/5d4ed304c0b4da5caf40c0469284b2338694441a)) + ## [2.1.0](https://github.com/googleapis/java-video-intelligence/compare/v2.0.27...v2.1.0) (2022-05-19) diff --git a/README.md b/README.md index 65a0418bc..732b88d82 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import @@ -45,12 +45,12 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-video-intelligence - 2.0.27 + 2.1.0 com.google.cloud google-cloud-storage - 2.6.1 + 2.7.0 ``` @@ -58,20 +58,20 @@ If you are using Maven without BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies ```Groovy -implementation platform('com.google.cloud:libraries-bom:25.3.0') +implementation platform('com.google.cloud:libraries-bom:25.4.0') implementation 'com.google.cloud:google-cloud-video-intelligence' ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-video-intelligence:2.0.27' +implementation 'com.google.cloud:google-cloud-video-intelligence:2.1.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-video-intelligence" % "2.0.27" +libraryDependencies += "com.google.cloud" % "google-cloud-video-intelligence" % "2.1.0" ``` ## Authentication diff --git a/google-cloud-video-intelligence-bom/pom.xml b/google-cloud-video-intelligence-bom/pom.xml index 8ed3049cb..65b213399 100644 --- a/google-cloud-video-intelligence-bom/pom.xml +++ b/google-cloud-video-intelligence-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-video-intelligence-bom - 2.1.0 + 2.2.0 pom com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 Google Cloud video-intelligence BOM @@ -52,57 +52,57 @@ com.google.cloud google-cloud-video-intelligence - 2.1.0 + 2.2.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p1beta1 - 0.91.0 + 0.92.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1beta2 - 0.91.0 + 0.92.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1 - 2.1.0 + 2.2.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p2beta1 - 0.91.0 + 0.92.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p3beta1 - 0.91.0 + 0.92.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1p3beta1 - 0.91.0 + 0.92.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1beta2 - 0.91.0 + 0.92.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1p1beta1 - 0.91.0 + 0.92.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1 - 2.1.0 + 2.2.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1p2beta1 - 0.91.0 + 0.92.0 diff --git a/google-cloud-video-intelligence/pom.xml b/google-cloud-video-intelligence/pom.xml index f97600bbb..ff9ce8b24 100644 --- a/google-cloud-video-intelligence/pom.xml +++ b/google-cloud-video-intelligence/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-video-intelligence - 2.1.0 + 2.2.0 jar Google Cloud Video Intelligence https://github.com/googleapis/java-video-intelligence @@ -11,7 +11,7 @@ com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 google-cloud-video-intelligence @@ -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 a45f40812..778296692 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 @@ -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.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; @@ -100,13 +100,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 { @@ -127,7 +143,6 @@ public static final VideoIntelligenceServiceClient create( * Constructs an instance of VideoIntelligenceServiceClient, using the given stub for making * calls. This is for advanced usage - prefer using create(VideoIntelligenceServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final VideoIntelligenceServiceClient create(VideoIntelligenceServiceStub stub) { return new VideoIntelligenceServiceClient(stub); } @@ -141,21 +156,23 @@ 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()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") 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() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub getStub() { return stub; } @@ -164,10 +181,19 @@ 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. + */ + @BetaApi + 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 a2c491d48..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; @@ -107,13 +110,17 @@ public UnaryCallSettings annotateVideoSettings( return annotateVideoOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .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 +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)) @@ -165,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); @@ -266,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 3e7de3fae..cb563d970 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 { @@ -128,7 +144,6 @@ public static final VideoIntelligenceServiceClient create( * Constructs an instance of VideoIntelligenceServiceClient, using the given stub for making * calls. This is for advanced usage - prefer using create(VideoIntelligenceServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final VideoIntelligenceServiceClient create(VideoIntelligenceServiceStub stub) { return new VideoIntelligenceServiceClient(stub); } @@ -142,21 +157,23 @@ 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()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") 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() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub getStub() { return stub; } @@ -165,10 +182,19 @@ 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. + */ + @BetaApi + 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 afcb871a7..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; @@ -108,13 +111,17 @@ public UnaryCallSettings annotateVideoSettings( return annotateVideoOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .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())); @@ -147,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)) @@ -166,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); @@ -267,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 83024ccbf..135f15b16 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 { @@ -128,7 +144,6 @@ public static final VideoIntelligenceServiceClient create( * Constructs an instance of VideoIntelligenceServiceClient, using the given stub for making * calls. This is for advanced usage - prefer using create(VideoIntelligenceServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final VideoIntelligenceServiceClient create(VideoIntelligenceServiceStub stub) { return new VideoIntelligenceServiceClient(stub); } @@ -142,21 +157,23 @@ 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()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") 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() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub getStub() { return stub; } @@ -165,10 +182,19 @@ 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. + */ + @BetaApi + 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 546b8315e..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; @@ -108,13 +111,17 @@ public UnaryCallSettings annotateVideoSettings( return annotateVideoOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .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())); @@ -147,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)) @@ -166,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); @@ -267,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 2a67c7c67..7fce79092 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 { @@ -128,7 +144,6 @@ public static final VideoIntelligenceServiceClient create( * Constructs an instance of VideoIntelligenceServiceClient, using the given stub for making * calls. This is for advanced usage - prefer using create(VideoIntelligenceServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final VideoIntelligenceServiceClient create(VideoIntelligenceServiceStub stub) { return new VideoIntelligenceServiceClient(stub); } @@ -142,21 +157,23 @@ 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()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") 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() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub getStub() { return stub; } @@ -165,10 +182,19 @@ 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. + */ + @BetaApi + 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 6e6cef7b7..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; @@ -108,13 +111,17 @@ public UnaryCallSettings annotateVideoSettings( return annotateVideoOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .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())); @@ -147,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)) @@ -166,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); @@ -267,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 e9caa4e86..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 @@ -126,7 +142,6 @@ public static final StreamingVideoIntelligenceServiceClient create( * making calls. This is for advanced usage - prefer using * create(StreamingVideoIntelligenceServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final StreamingVideoIntelligenceServiceClient create( StreamingVideoIntelligenceServiceStub stub) { return new StreamingVideoIntelligenceServiceClient(stub); @@ -144,7 +159,6 @@ protected StreamingVideoIntelligenceServiceClient( ((StreamingVideoIntelligenceServiceStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected StreamingVideoIntelligenceServiceClient(StreamingVideoIntelligenceServiceStub stub) { this.settings = null; this.stub = stub; @@ -154,7 +168,6 @@ public final StreamingVideoIntelligenceServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public StreamingVideoIntelligenceServiceStub getStub() { return stub; } 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 2617c2fad..74701de19 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 { @@ -128,7 +144,6 @@ public static final VideoIntelligenceServiceClient create( * Constructs an instance of VideoIntelligenceServiceClient, using the given stub for making * calls. This is for advanced usage - prefer using create(VideoIntelligenceServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final VideoIntelligenceServiceClient create(VideoIntelligenceServiceStub stub) { return new VideoIntelligenceServiceClient(stub); } @@ -142,21 +157,23 @@ 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()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") 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() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub getStub() { return stub; } @@ -165,10 +182,19 @@ 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. + */ + @BetaApi + 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 b0c82ef09..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; @@ -97,13 +100,17 @@ public class StreamingVideoIntelligenceServiceStubSettings return streamingAnnotateVideoSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public StreamingVideoIntelligenceServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .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())); @@ -136,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", @@ -156,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); @@ -252,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 eaf254704..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; @@ -108,13 +111,17 @@ public UnaryCallSettings annotateVideoSettings( return annotateVideoOperationSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public VideoIntelligenceServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .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())); @@ -147,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)) @@ -166,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); @@ -267,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/grpc-google-cloud-video-intelligence-v1/pom.xml b/grpc-google-cloud-video-intelligence-v1/pom.xml index 114fb03d6..c996a5477 100644 --- a/grpc-google-cloud-video-intelligence-v1/pom.xml +++ b/grpc-google-cloud-video-intelligence-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1 - 2.1.0 + 2.2.0 grpc-google-cloud-video-intelligence-v1 GRPC library for grpc-google-cloud-video-intelligence-v1 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/grpc-google-cloud-video-intelligence-v1beta2/pom.xml b/grpc-google-cloud-video-intelligence-v1beta2/pom.xml index 5fb6f758a..28a917983 100644 --- a/grpc-google-cloud-video-intelligence-v1beta2/pom.xml +++ b/grpc-google-cloud-video-intelligence-v1beta2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1beta2 - 0.91.0 + 0.92.0 grpc-google-cloud-video-intelligence-v1beta2 GRPC library for grpc-google-cloud-video-intelligence-v1beta2 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/grpc-google-cloud-video-intelligence-v1p1beta1/pom.xml b/grpc-google-cloud-video-intelligence-v1p1beta1/pom.xml index 949f311e2..2d7e2b4b5 100644 --- a/grpc-google-cloud-video-intelligence-v1p1beta1/pom.xml +++ b/grpc-google-cloud-video-intelligence-v1p1beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p1beta1 - 0.91.0 + 0.92.0 grpc-google-cloud-video-intelligence-v1p1beta1 GRPC library for grpc-google-cloud-video-intelligence-v1p1beta1 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/grpc-google-cloud-video-intelligence-v1p2beta1/pom.xml b/grpc-google-cloud-video-intelligence-v1p2beta1/pom.xml index ea1a083b1..52e199c13 100644 --- a/grpc-google-cloud-video-intelligence-v1p2beta1/pom.xml +++ b/grpc-google-cloud-video-intelligence-v1p2beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p2beta1 - 0.91.0 + 0.92.0 grpc-google-cloud-video-intelligence-v1p2beta1 GRPC library for grpc-google-cloud-video-intelligence-v1p2beta1 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/grpc-google-cloud-video-intelligence-v1p3beta1/pom.xml b/grpc-google-cloud-video-intelligence-v1p3beta1/pom.xml index da6440966..b5e0897b0 100644 --- a/grpc-google-cloud-video-intelligence-v1p3beta1/pom.xml +++ b/grpc-google-cloud-video-intelligence-v1p3beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p3beta1 - 0.91.0 + 0.92.0 grpc-google-cloud-video-intelligence-v1p3beta1 GRPC library for grpc-google-cloud-video-intelligence-v1p3beta1 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/pom.xml b/pom.xml index 23a461836..67df0a8e2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-video-intelligence-parent pom - 2.1.0 + 2.2.0 Google Cloud Video Intelligence Parent https://github.com/googleapis/java-video-intelligence @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 @@ -61,68 +61,68 @@ com.google.api.grpc proto-google-cloud-video-intelligence-v1p3beta1 - 0.91.0 + 0.92.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1beta2 - 0.91.0 + 0.92.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1p1beta1 - 0.91.0 + 0.92.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1 - 2.1.0 + 2.2.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1p2beta1 - 0.91.0 + 0.92.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p1beta1 - 0.91.0 + 0.92.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1beta2 - 0.91.0 + 0.92.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1 - 2.1.0 + 2.2.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p2beta1 - 0.91.0 + 0.92.0 com.google.api.grpc grpc-google-cloud-video-intelligence-v1p3beta1 - 0.91.0 + 0.92.0 com.google.cloud google-cloud-video-intelligence - 2.1.0 + 2.2.0 com.google.cloud google-cloud-video-intelligence-bom - 2.0.27 + 2.1.0 com.google.cloud google-cloud-shared-dependencies - 2.12.0 + 2.13.0 pom import diff --git a/proto-google-cloud-video-intelligence-v1/pom.xml b/proto-google-cloud-video-intelligence-v1/pom.xml index d73becbef..1929888c9 100644 --- a/proto-google-cloud-video-intelligence-v1/pom.xml +++ b/proto-google-cloud-video-intelligence-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1 - 2.1.0 + 2.2.0 proto-google-cloud-video-intelligence-v1 PROTO library for proto-google-cloud-video-intelligence-v1 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/proto-google-cloud-video-intelligence-v1beta2/pom.xml b/proto-google-cloud-video-intelligence-v1beta2/pom.xml index 95ce8e45d..1326bc438 100644 --- a/proto-google-cloud-video-intelligence-v1beta2/pom.xml +++ b/proto-google-cloud-video-intelligence-v1beta2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1beta2 - 0.91.0 + 0.92.0 proto-google-cloud-video-intelligence-v1beta2 PROTO library for proto-google-cloud-video-intelligence-v1beta2 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/proto-google-cloud-video-intelligence-v1p1beta1/pom.xml b/proto-google-cloud-video-intelligence-v1p1beta1/pom.xml index 08cc16e98..599ece8c1 100644 --- a/proto-google-cloud-video-intelligence-v1p1beta1/pom.xml +++ b/proto-google-cloud-video-intelligence-v1p1beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1p1beta1 - 0.91.0 + 0.92.0 proto-google-cloud-video-intelligence-v1p1beta1 PROTO library for proto-google-cloud-video-intelligence-v1p1beta1 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/proto-google-cloud-video-intelligence-v1p2beta1/pom.xml b/proto-google-cloud-video-intelligence-v1p2beta1/pom.xml index 4f0eb319c..1f7cf68f9 100644 --- a/proto-google-cloud-video-intelligence-v1p2beta1/pom.xml +++ b/proto-google-cloud-video-intelligence-v1p2beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1p2beta1 - 0.91.0 + 0.92.0 proto-google-cloud-video-intelligence-v1p2beta1 PROTO library for proto-google-cloud-video-intelligence-v1p2beta1 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/proto-google-cloud-video-intelligence-v1p3beta1/pom.xml b/proto-google-cloud-video-intelligence-v1p3beta1/pom.xml index f17271ca3..85c888c76 100644 --- a/proto-google-cloud-video-intelligence-v1p3beta1/pom.xml +++ b/proto-google-cloud-video-intelligence-v1p3beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-video-intelligence-v1p3beta1 - 0.91.0 + 0.92.0 proto-google-cloud-video-intelligence-v1p3beta1 PROTO library for proto-google-cloud-video-intelligence-v1p3beta1 com.google.cloud google-cloud-video-intelligence-parent - 2.1.0 + 2.2.0 diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index daafddd0c..2df06f2ba 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,18 +29,18 @@ com.google.cloud google-cloud-video-intelligence - 2.0.27 + 2.1.0 com.google.cloud google-cloud-storage - 2.6.1 + 2.7.0 com.google.cloud google-cloud-storage - 2.6.1 + 2.7.0 @@ -58,7 +58,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 test tests diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 3e72145d4..e26197999 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,13 +28,13 @@ com.google.cloud google-cloud-video-intelligence - 2.1.0 + 2.2.0 com.google.cloud google-cloud-storage - 2.6.1 + 2.7.0 @@ -52,7 +52,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 test tests 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..5e828421e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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_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..3963d0877 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..f252944c4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..4e2e757f5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/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.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..b2c15855c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/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.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..c2935ec4f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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_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..4aecb28a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..6b025c883 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..bef39c8e6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1beta2/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.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..ee211c508 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/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.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..e4ebb4cb7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/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.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..daae83bf0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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_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..97dcbcd75 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..00b0405da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..3400284e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p1beta1/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.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..8dfbb2d43 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/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.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..433a7749c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/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.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..88e048758 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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_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..d554c1034 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..b99606c79 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..1750f1c4b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p2beta1/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.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..6e36612a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..de9f6e263 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..89543210f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/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.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..5c2a1d4c4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceserviceclient/streamingannotatevideo/AsyncStreamingAnnotateVideo.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_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..f266ca084 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/streamingvideointelligenceservicesettings/streamingannotatevideo/SyncStreamingAnnotateVideo.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_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..6ec943ae1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/stub/streamingvideointelligenceservicestubsettings/streamingannotatevideo/SyncStreamingAnnotateVideo.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.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..7d06b2d2b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/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.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..104d51222 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/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.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..f324054a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/annotatevideo/SyncAnnotateVideoStringListfeature.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_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..93048434a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..c22af42ec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/videointelligenceserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.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..1650f7527 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/videointelligence/v1p3beta1/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.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] diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 45b56cf7c..8a53f1cba 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import @@ -63,7 +63,7 @@ com.google.cloud google-cloud-core - 2.7.1 + 2.8.0 test tests diff --git a/versions.txt b/versions.txt index 6d8d79e35..8b462aaa1 100644 --- a/versions.txt +++ b/versions.txt @@ -1,14 +1,14 @@ # Format: # module:released-version:current-version -google-cloud-video-intelligence:2.1.0:2.1.0 -grpc-google-cloud-video-intelligence-v1p1beta1:0.91.0:0.91.0 -grpc-google-cloud-video-intelligence-v1beta2:0.91.0:0.91.0 -grpc-google-cloud-video-intelligence-v1:2.1.0:2.1.0 -grpc-google-cloud-video-intelligence-v1p2beta1:0.91.0:0.91.0 -grpc-google-cloud-video-intelligence-v1p3beta1:0.91.0:0.91.0 -proto-google-cloud-video-intelligence-v1p3beta1:0.91.0:0.91.0 -proto-google-cloud-video-intelligence-v1beta2:0.91.0:0.91.0 -proto-google-cloud-video-intelligence-v1p1beta1:0.91.0:0.91.0 -proto-google-cloud-video-intelligence-v1:2.1.0:2.1.0 -proto-google-cloud-video-intelligence-v1p2beta1:0.91.0:0.91.0 +google-cloud-video-intelligence:2.2.0:2.2.0 +grpc-google-cloud-video-intelligence-v1p1beta1:0.92.0:0.92.0 +grpc-google-cloud-video-intelligence-v1beta2:0.92.0:0.92.0 +grpc-google-cloud-video-intelligence-v1:2.2.0:2.2.0 +grpc-google-cloud-video-intelligence-v1p2beta1:0.92.0:0.92.0 +grpc-google-cloud-video-intelligence-v1p3beta1:0.92.0:0.92.0 +proto-google-cloud-video-intelligence-v1p3beta1:0.92.0:0.92.0 +proto-google-cloud-video-intelligence-v1beta2:0.92.0:0.92.0 +proto-google-cloud-video-intelligence-v1p1beta1:0.92.0:0.92.0 +proto-google-cloud-video-intelligence-v1:2.2.0:2.2.0 +proto-google-cloud-video-intelligence-v1p2beta1:0.92.0:0.92.0