From 8bc63f4e5645dc626e502c3a5d2546dfd0286d61 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Wed, 2 Dec 2020 13:27:08 -0800 Subject: [PATCH 1/3] fix: fix dep ordering in Bazel dedupe rules --- rules_java_gapic/java_gapic.bzl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rules_java_gapic/java_gapic.bzl b/rules_java_gapic/java_gapic.bzl index 96e482907c..d265f8c676 100644 --- a/rules_java_gapic/java_gapic.bzl +++ b/rules_java_gapic/java_gapic.bzl @@ -189,7 +189,7 @@ def java_gapic_library( ) # General additional deps. - actual_deps = resource_name_deps + [ + actual_deps = deps + resource_name_deps + [ "@com_google_googleapis//google/rpc:rpc_java_proto", "@com_google_googleapis//google/longrunning:longrunning_java_proto", "@com_google_protobuf//:protobuf_java", @@ -207,7 +207,6 @@ def java_gapic_library( "@com_google_http_client_google_http_client//jar", "@javax_annotation_javax_annotation_api//jar", ] - _append_dep_without_duplicates(actual_deps, deps) native.java_library( name = name, From d06bb471a2be7b0c4aef31ba4ef656d5d7fad4b2 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Thu, 7 Jan 2021 17:09:07 -0800 Subject: [PATCH 2/3] feat: Add alpha/beta API detection and fix per-class annotations --- ...pcServiceCallableFactoryClassComposer.java | 16 +- .../GrpcServiceStubClassComposer.java | 14 +- .../composer/ServiceClientClassComposer.java | 15 +- .../ServiceSettingsClassComposer.java | 12 +- .../composer/ServiceStubClassComposer.java | 16 +- .../ServiceStubSettingsClassComposer.java | 13 +- .../gapic/composer/utils/BUILD.bazel | 1 + .../gapic/composer/utils/PackageChecker.java | 44 ++ .../gapic/composer/constants/BUILD.bazel | 2 - .../gapic/composer/goldens/EchoClient.golden | 2 +- .../composer/goldens/EchoSettings.golden | 1 + .../gapic/composer/goldens/EchoStub.golden | 4 +- .../goldens/GrpcEchoCallableFactory.golden | 4 +- .../composer/goldens/GrpcEchoStub.golden | 2 + .../composer/goldens/GrpcTestingStub.golden | 2 + .../composer/goldens/IdentityClient.golden | 2 +- .../LoggingServiceV2StubSettings.golden | 1 - .../goldens/PublisherStubSettings.golden | 1 - .../gapic/composer/utils/BUILD.bazel | 30 + .../composer/utils/PackageCheckerTest.java | 46 ++ test/integration/BUILD.bazel | 18 +- .../goldens/asset/AssetServiceClient.java | 654 +----------------- .../goldens/asset/AssetServiceClientTest.java | 388 +---------- .../goldens/asset/AssetServiceSettings.java | 92 +-- .../goldens/asset/AssetServiceStub.java | 69 +- .../asset/AssetServiceStubSettings.java | 365 +--------- test/integration/goldens/asset/FeedName.java | 368 ---------- .../GrpcAssetServiceCallableFactory.java | 6 +- .../goldens/asset/GrpcAssetServiceStub.java | 275 +------- .../goldens/asset/MockAssetService.java | 2 +- .../goldens/asset/MockAssetServiceImpl.java | 108 +-- .../goldens/asset/PlaceholderFile.java | 0 .../goldens/asset/package-info.java | 2 +- .../GrpcIamCredentialsCallableFactory.java | 2 +- .../credentials/IamCredentialsClient.java | 3 +- .../credentials/IamCredentialsStub.java | 2 +- .../IamCredentialsStubSettings.java | 1 - .../GrpcLibraryServiceCallableFactory.java | 2 +- .../goldens/library/LibraryServiceClient.java | 3 +- .../goldens/library/LibraryServiceStub.java | 2 +- .../library/LibraryServiceStubSettings.java | 1 - .../goldens/logging/ConfigClient.java | 3 +- .../goldens/logging/ConfigServiceV2Stub.java | 2 +- .../logging/ConfigServiceV2StubSettings.java | 1 - .../GrpcConfigServiceV2CallableFactory.java | 2 +- .../GrpcLoggingServiceV2CallableFactory.java | 2 +- .../GrpcMetricsServiceV2CallableFactory.java | 2 +- .../goldens/logging/LoggingClient.java | 3 +- .../goldens/logging/LoggingServiceV2Stub.java | 2 +- .../logging/LoggingServiceV2StubSettings.java | 1 - .../goldens/logging/MetricsClient.java | 3 +- .../goldens/logging/MetricsServiceV2Stub.java | 2 +- .../logging/MetricsServiceV2StubSettings.java | 1 - .../goldens/redis/CloudRedisClient.java | 3 +- .../goldens/redis/CloudRedisStub.java | 2 +- .../goldens/redis/CloudRedisStubSettings.java | 1 - .../redis/GrpcCloudRedisCallableFactory.java | 2 +- 57 files changed, 288 insertions(+), 2335 deletions(-) create mode 100644 src/main/java/com/google/api/generator/gapic/composer/utils/PackageChecker.java create mode 100644 src/test/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel create mode 100644 src/test/java/com/google/api/generator/gapic/composer/utils/PackageCheckerTest.java delete mode 100644 test/integration/goldens/asset/FeedName.java create mode 100644 test/integration/goldens/asset/PlaceholderFile.java diff --git a/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposer.java index 672a35804f..4a7b7375ef 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceCallableFactoryClassComposer.java @@ -14,6 +14,7 @@ package com.google.api.generator.gapic.composer; +import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -40,6 +41,7 @@ import com.google.api.generator.gapic.composer.comment.StubCommentComposer; import com.google.api.generator.gapic.composer.store.TypeStore; import com.google.api.generator.gapic.composer.utils.ClassNames; +import com.google.api.generator.gapic.composer.utils.PackageChecker; import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; @@ -77,7 +79,7 @@ public GapicClass generate(Service service, Map ignore) { .setHeaderCommentStatements( StubCommentComposer.createGrpcServiceCallableFactoryClassHeaderComments( service.name())) - .setAnnotations(createClassAnnotations(typeStore)) + .setAnnotations(createClassAnnotations(service.pakkage(), typeStore)) .setImplementsTypes(createClassImplements(typeStore)) .setName(className) .setMethods(createClassMethods(typeStore)) @@ -86,12 +88,17 @@ public GapicClass generate(Service service, Map ignore) { return GapicClass.create(kind, classDef); } - private static List createClassAnnotations(TypeStore typeStore) { - return Arrays.asList( + private static List createClassAnnotations(String pakkage, TypeStore typeStore) { + List annotations = new ArrayList<>(); + if (!PackageChecker.isGaApi(pakkage)) { + annotations.add(AnnotationNode.withType(typeStore.get("BetaApi"))); + } + annotations.add( AnnotationNode.builder() .setType(typeStore.get("Generated")) - .setDescription("by gapic-generator") + .setDescription("by gapic-generator-java") .build()); + return annotations; } private static List createClassImplements(TypeStore typeStore) { @@ -343,6 +350,7 @@ private static TypeStore createTypes(Service service) { Arrays.asList( // Gax-java classes. BatchingCallSettings.class, + BetaApi.class, BidiStreamingCallable.class, ClientContext.class, ClientStreamingCallable.class, diff --git a/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposer.java index a43f27b91a..f05a0e057d 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/GrpcServiceStubClassComposer.java @@ -14,6 +14,7 @@ package com.google.api.generator.gapic.composer; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -51,6 +52,7 @@ import com.google.api.generator.gapic.composer.comment.StubCommentComposer; import com.google.api.generator.gapic.composer.store.TypeStore; import com.google.api.generator.gapic.composer.utils.ClassNames; +import com.google.api.generator.gapic.composer.utils.PackageChecker; import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; @@ -161,7 +163,7 @@ public GapicClass generate(Service service, Map ignore) { .setPackageString(pakkage) .setHeaderCommentStatements( StubCommentComposer.createGrpcServiceStubClassHeaderComments(service.name())) - .setAnnotations(createClassAnnotations()) + .setAnnotations(createClassAnnotations(service.pakkage())) .setScope(ScopeNode.PUBLIC) .setName(className) .setExtendsType(typeStore.get(ClassNames.getServiceStubClassName(service))) @@ -385,12 +387,17 @@ private static Map createCallableClassMembers( return callableClassMembers; } - private static List createClassAnnotations() { - return Arrays.asList( + private static List createClassAnnotations(String pakkage) { + List annotations = new ArrayList<>(); + if (!PackageChecker.isGaApi(pakkage)) { + annotations.add(AnnotationNode.withType(FIXED_TYPESTORE.get("BetaApi"))); + } + annotations.add( AnnotationNode.builder() .setType(FIXED_TYPESTORE.get("Generated")) .setDescription("by gapic-generator-java") .build()); + return annotations; } private static List createClassMethods( @@ -1024,6 +1031,7 @@ private static TypeStore createStaticTypes() { Arrays.asList( BackgroundResource.class, BackgroundResourceAggregation.class, + BetaApi.class, BidiStreamingCallable.class, ClientContext.class, ClientStreamingCallable.class, diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java index 3c82ab145d..477a2b68a5 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientClassComposer.java @@ -58,6 +58,7 @@ import com.google.api.generator.gapic.composer.samplecode.ServiceClientSampleCodeComposer; import com.google.api.generator.gapic.composer.store.TypeStore; import com.google.api.generator.gapic.composer.utils.ClassNames; +import com.google.api.generator.gapic.composer.utils.PackageChecker; import com.google.api.generator.gapic.model.Field; import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicClass.Kind; @@ -128,7 +129,7 @@ public GapicClass generate(Service service, Map messageTypes) { ClassDefinition.builder() .setHeaderCommentStatements(createClassHeaderComments(service, typeStore)) .setPackageString(pakkage) - .setAnnotations(createClassAnnotations(typeStore)) + .setAnnotations(createClassAnnotations(pakkage, typeStore)) .setScope(ScopeNode.PUBLIC) .setName(className) .setImplementsTypes(createClassImplements(typeStore)) @@ -139,13 +140,17 @@ public GapicClass generate(Service service, Map messageTypes) { return GapicClass.create(kind, classDef); } - private static List createClassAnnotations(TypeStore typeStore) { - return Arrays.asList( - AnnotationNode.withType(typeStore.get("BetaApi")), + private static List createClassAnnotations(String pakkage, TypeStore typeStore) { + List annotations = new ArrayList<>(); + if (!PackageChecker.isGaApi(pakkage)) { + annotations.add(AnnotationNode.withType(typeStore.get("BetaApi"))); + } + annotations.add( AnnotationNode.builder() .setType(typeStore.get("Generated")) - .setDescription("by gapic-generator") + .setDescription("by gapic-generator-java") .build()); + return annotations; } private static List createClassImplements(TypeStore typeStore) { diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposer.java index 8af3e88e38..37758868e0 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceSettingsClassComposer.java @@ -54,6 +54,7 @@ import com.google.api.generator.gapic.composer.samplecode.SettingsSampleCodeComposer; import com.google.api.generator.gapic.composer.store.TypeStore; import com.google.api.generator.gapic.composer.utils.ClassNames; +import com.google.api.generator.gapic.composer.utils.PackageChecker; import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; @@ -104,7 +105,7 @@ public GapicClass generate(Service service, Map ignore) { .setPackageString(pakkage) .setHeaderCommentStatements( createClassHeaderComments(service, typeStore.get(className))) - .setAnnotations(createClassAnnotations()) + .setAnnotations(createClassAnnotations(service.pakkage())) .setScope(ScopeNode.PUBLIC) .setName(className) .setExtendsType( @@ -147,12 +148,17 @@ private static List createClassHeaderComments( classType); } - private static List createClassAnnotations() { - return Arrays.asList( + private static List createClassAnnotations(String pakkage) { + List annotations = new ArrayList<>(); + if (!PackageChecker.isGaApi(pakkage)) { + annotations.add(AnnotationNode.withType(FIXED_TYPESTORE.get("BetaApi"))); + } + annotations.add( AnnotationNode.builder() .setType(FIXED_TYPESTORE.get("Generated")) .setDescription("by gapic-generator-java") .build()); + return annotations; } private static List createClassMethods(Service service, TypeStore typeStore) { diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubClassComposer.java index 005b1415cb..f2f70a6e8e 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubClassComposer.java @@ -14,6 +14,7 @@ package com.google.api.generator.gapic.composer; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.BidiStreamingCallable; import com.google.api.gax.rpc.ClientStreamingCallable; @@ -32,6 +33,7 @@ import com.google.api.generator.gapic.composer.comment.StubCommentComposer; import com.google.api.generator.gapic.composer.store.TypeStore; import com.google.api.generator.gapic.composer.utils.ClassNames; +import com.google.api.generator.gapic.composer.utils.PackageChecker; import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.Message; @@ -69,7 +71,7 @@ public GapicClass generate(Service service, Map messageTypes) { .setPackageString(pakkage) .setHeaderCommentStatements( StubCommentComposer.createServiceStubClassHeaderComments(service.name())) - .setAnnotations(createClassAnnotations(typeStore)) + .setAnnotations(createClassAnnotations(service.pakkage(), typeStore)) .setIsAbstract(true) .setImplementsTypes(createClassImplements(typeStore)) .setName(className) @@ -79,12 +81,17 @@ public GapicClass generate(Service service, Map messageTypes) { return GapicClass.create(kind, classDef); } - private static List createClassAnnotations(TypeStore typeStore) { - return Arrays.asList( + private static List createClassAnnotations(String pakkage, TypeStore typeStore) { + List annotations = new ArrayList<>(); + if (!PackageChecker.isGaApi(pakkage)) { + annotations.add(AnnotationNode.withType(typeStore.get("BetaApi"))); + } + annotations.add( AnnotationNode.builder() .setType(typeStore.get("Generated")) - .setDescription("by gapic-generator") + .setDescription("by gapic-generator-java") .build()); + return annotations; } private static List createClassImplements(TypeStore typeStore) { @@ -215,6 +222,7 @@ private static TypeStore createTypes(Service service, Map messa List concreteClazzes = Arrays.asList( BackgroundResource.class, + BetaApi.class, BidiStreamingCallable.class, ClientStreamingCallable.class, Generated.class, diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java index e0352303d7..2753fb6faf 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java @@ -85,6 +85,7 @@ import com.google.api.generator.gapic.composer.samplecode.SettingsSampleCodeComposer; import com.google.api.generator.gapic.composer.store.TypeStore; import com.google.api.generator.gapic.composer.utils.ClassNames; +import com.google.api.generator.gapic.composer.utils.PackageChecker; import com.google.api.generator.gapic.model.Field; import com.google.api.generator.gapic.model.GapicBatchingSettings; import com.google.api.generator.gapic.model.GapicClass; @@ -175,7 +176,7 @@ public GapicClass generate( .setPackageString(pakkage) .setHeaderCommentStatements( createClassHeaderComments(service, typeStore.get(className))) - .setAnnotations(createClassAnnotations()) + .setAnnotations(createClassAnnotations(service.pakkage())) .setScope(ScopeNode.PUBLIC) .setName(className) .setExtendsType(createExtendsType(service, typeStore)) @@ -189,13 +190,17 @@ public GapicClass generate( return GapicClass.create(GapicClass.Kind.STUB, classDef); } - private static List createClassAnnotations() { - return Arrays.asList( - AnnotationNode.withType(FIXED_TYPESTORE.get("BetaApi")), + private static List createClassAnnotations(String pakkage) { + List annotations = new ArrayList<>(); + if (!PackageChecker.isGaApi(pakkage)) { + annotations.add(AnnotationNode.withType(FIXED_TYPESTORE.get("BetaApi"))); + } + annotations.add( AnnotationNode.builder() .setType(FIXED_TYPESTORE.get("Generated")) .setDescription("by gapic-generator-java") .build()); + return annotations; } private static List createClassHeaderComments( diff --git a/src/main/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel b/src/main/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel index dbcf57db8a..2ecfd68fb0 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel +++ b/src/main/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel @@ -14,5 +14,6 @@ java_library( ], deps = [ "//src/main/java/com/google/api/generator/gapic/model", + "@com_google_guava_guava//jar", ], ) diff --git a/src/main/java/com/google/api/generator/gapic/composer/utils/PackageChecker.java b/src/main/java/com/google/api/generator/gapic/composer/utils/PackageChecker.java new file mode 100644 index 0000000000..9765df0425 --- /dev/null +++ b/src/main/java/com/google/api/generator/gapic/composer/utils/PackageChecker.java @@ -0,0 +1,44 @@ +// Copyright 2021 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 +// +// http://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.api.generator.gapic.composer.utils; + +import com.google.common.base.Preconditions; +import com.google.common.base.Strings; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PackageChecker { + private PackageChecker() {} + + /** + * Identifies whether a Java package is GA API. Assumes that the version appears in the last + * component of the package, e.g. com.google.cloud.dataproc.v1beta1. + */ + public static boolean isGaApi(String pakkage) { + String[] packageComponents = pakkage.split("\\."); + Preconditions.checkState( + packageComponents.length > 0, "No subcomponents found in Java package %s", pakkage); + String versionComponent = packageComponents[packageComponents.length - 1]; + Matcher matcher = Pattern.compile("^v[0-9]+").matcher(versionComponent); + Preconditions.checkState( + matcher.find(), + "No version component found in last subpackage %s of %s", + versionComponent, + pakkage); + String versionSubstr = versionComponent.replace(matcher.group(), ""); + return Strings.isNullOrEmpty(versionSubstr) + || (!versionSubstr.contains("alpha") && !versionSubstr.contains("beta")); + } +} diff --git a/src/test/java/com/google/api/generator/gapic/composer/constants/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/constants/BUILD.bazel index 2288521d30..d77098ae19 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/constants/BUILD.bazel +++ b/src/test/java/com/google/api/generator/gapic/composer/constants/BUILD.bazel @@ -1,5 +1,3 @@ -load("@rules_java//java:defs.bzl", "java_library") - package(default_visibility = ["//visibility:public"]) filegroup( diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden index f6495514d6..3dc3eaffe0 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoClient.golden @@ -80,7 +80,7 @@ import javax.annotation.Generated; *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class EchoClient implements BackgroundResource { private final EchoSettings settings; private final EchoStub stub; diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoSettings.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoSettings.golden index ceb903e029..d94e7838ef 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoSettings.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoSettings.golden @@ -55,6 +55,7 @@ import javax.annotation.Generated; * EchoSettings echoSettings = echoSettingsBuilder.build(); * } */ +@BetaApi @Generated("by gapic-generator-java") public class EchoSettings extends ClientSettings { diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoStub.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoStub.golden index 9d3eac8add..629e9939bb 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/EchoStub.golden @@ -3,6 +3,7 @@ package com.google.showcase.v1beta1.stub; import static com.google.showcase.v1beta1.EchoClient.PagedExpandPagedResponse; import static com.google.showcase.v1beta1.EchoClient.SimplePagedExpandPagedResponse; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.BidiStreamingCallable; import com.google.api.gax.rpc.ClientStreamingCallable; @@ -29,7 +30,8 @@ import javax.annotation.Generated; * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public abstract class EchoStub implements BackgroundResource { public OperationsStub getOperationsStub() { diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcEchoCallableFactory.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcEchoCallableFactory.golden index 0786cd3d1b..d6ac9c9fe7 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcEchoCallableFactory.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcEchoCallableFactory.golden @@ -1,5 +1,6 @@ package com.google.showcase.v1beta1.stub; +import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -25,7 +26,8 @@ import javax.annotation.Generated; * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public class GrpcEchoCallableFactory implements GrpcStubCallableFactory { @Override diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcEchoStub.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcEchoStub.golden index bd53044979..3c32fbab4f 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcEchoStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcEchoStub.golden @@ -3,6 +3,7 @@ package com.google.showcase.v1beta1.stub; import static com.google.showcase.v1beta1.EchoClient.PagedExpandPagedResponse; import static com.google.showcase.v1beta1.EchoClient.SimplePagedExpandPagedResponse; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -37,6 +38,7 @@ import javax.annotation.Generated; * *

This class is for advanced usage and reflects the underlying API directly. */ +@BetaApi @Generated("by gapic-generator-java") public class GrpcEchoStub extends EchoStub { private static final MethodDescriptor echoMethodDescriptor = diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcTestingStub.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcTestingStub.golden index f5ffa8f0b8..5c6a4e4626 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcTestingStub.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/GrpcTestingStub.golden @@ -3,6 +3,7 @@ package com.google.showcase.v1beta1.stub; import static com.google.showcase.v1beta1.TestingClient.ListSessionsPagedResponse; import static com.google.showcase.v1beta1.TestingClient.ListTestsPagedResponse; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -41,6 +42,7 @@ import javax.annotation.Generated; * *

This class is for advanced usage and reflects the underlying API directly. */ +@BetaApi @Generated("by gapic-generator-java") public class GrpcTestingStub extends TestingStub { private static final MethodDescriptor diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden index edd19b1601..40133002aa 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/IdentityClient.golden @@ -71,7 +71,7 @@ import javax.annotation.Generated; *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class IdentityClient implements BackgroundResource { private final IdentitySettings settings; private final IdentityStub stub; diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/LoggingServiceV2StubSettings.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/LoggingServiceV2StubSettings.golden index e4f242d816..29c1fe7941 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/LoggingServiceV2StubSettings.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/LoggingServiceV2StubSettings.golden @@ -88,7 +88,6 @@ import org.threeten.bp.Duration; * LoggingServiceV2StubSettings loggingServiceV2Settings = loggingServiceV2SettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class LoggingServiceV2StubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/src/test/java/com/google/api/generator/gapic/composer/goldens/PublisherStubSettings.golden b/src/test/java/com/google/api/generator/gapic/composer/goldens/PublisherStubSettings.golden index 2f19e405c1..41585255b2 100644 --- a/src/test/java/com/google/api/generator/gapic/composer/goldens/PublisherStubSettings.golden +++ b/src/test/java/com/google/api/generator/gapic/composer/goldens/PublisherStubSettings.golden @@ -91,7 +91,6 @@ import org.threeten.bp.Duration; * PublisherStubSettings publisherSettings = publisherSettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class PublisherStubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/src/test/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel b/src/test/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel new file mode 100644 index 0000000000..f33101e6f9 --- /dev/null +++ b/src/test/java/com/google/api/generator/gapic/composer/utils/BUILD.bazel @@ -0,0 +1,30 @@ +load("@rules_java//java:defs.bzl", "java_test") + +package(default_visibility = ["//visibility:public"]) + +TESTS = [ + "PackageCheckerTest", +] + +TEST_DEPS = [ + "//src/main/java/com/google/api/generator/gapic/composer/utils", + "@com_google_guava_guava", + "@com_google_protobuf//:protobuf_java", + "@com_google_truth_truth//jar", + "@junit_junit//jar", +] + +filegroup( + name = "utils_files", + srcs = ["{0}.java".format(f) for f in TESTS], +) + +[java_test( + name = test_name, + testonly = True, + srcs = [ + "{0}.java".format(test_name), + ], + test_class = "com.google.api.generator.gapic.composer.utils.{0}".format(test_name), + deps = TEST_DEPS, +) for test_name in TESTS] diff --git a/src/test/java/com/google/api/generator/gapic/composer/utils/PackageCheckerTest.java b/src/test/java/com/google/api/generator/gapic/composer/utils/PackageCheckerTest.java new file mode 100644 index 0000000000..323f5e0100 --- /dev/null +++ b/src/test/java/com/google/api/generator/gapic/composer/utils/PackageCheckerTest.java @@ -0,0 +1,46 @@ +// Copyright 2021 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 +// +// http://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.api.generator.gapic.composer.utils; + +import static junit.framework.Assert.assertFalse; +import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertThrows; + +import org.junit.Test; + +public class PackageCheckerTest { + @Test + public void isGaApi_normalExpectedPackageStructure() { + assertTrue(PackageChecker.isGaApi("com.google.cloud.dataproc.v1")); + assertTrue(PackageChecker.isGaApi("com.google.cloud.dataproc.v999")); + assertTrue(PackageChecker.isGaApi("com.google.cloud.dataproc.v12345a")); + assertTrue(PackageChecker.isGaApi("com.google.cloud.dataproc.v999asdf")); + assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1beta1")); + assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1alpha1")); + assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1beta")); + assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1alpha")); + assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1p2alpha1")); + assertFalse(PackageChecker.isGaApi("com.google.cloud.dataproc.v1p4beta")); + assertFalse(PackageChecker.isGaApi("com.google.cloud.asset.v1beta1")); + } + + @Test + public void isGaApi_invalidPackageStructure() { + assertThrows( + IllegalStateException.class, + () -> PackageChecker.isGaApi("com.google.cloud.dataproc.v1.foobar")); + assertThrows(IllegalStateException.class, () -> PackageChecker.isGaApi("")); + } +} diff --git a/test/integration/BUILD.bazel b/test/integration/BUILD.bazel index 777e1d0d93..aacf5e0805 100644 --- a/test/integration/BUILD.bazel +++ b/test/integration/BUILD.bazel @@ -45,14 +45,14 @@ INTEGRATION_TEST_LIBRARIES = [ # Asset API. java_gapic_library( name = "asset_java_gapic", - srcs = ["@com_google_googleapis//google/cloud/asset/v1:asset_proto_with_info"], - grpc_service_config = "@com_google_googleapis//google/cloud/asset/v1:cloudasset_grpc_service_config.json", + srcs = ["@com_google_googleapis//google/cloud/asset/v1beta1:asset_proto_with_info"], + grpc_service_config = "@com_google_googleapis//google/cloud/asset/v1beta1:cloudasset_grpc_service_config.json", test_deps = [ - "@com_google_googleapis//google/cloud/asset/v1:asset_java_grpc", + "@com_google_googleapis//google/cloud/asset/v1beta1:asset_java_grpc", "@com_google_googleapis//google/iam/v1:iam_java_grpc", ], deps = [ - "@com_google_googleapis//google/cloud/asset/v1:asset_java_proto", + "@com_google_googleapis//google/cloud/asset/v1beta1:asset_java_proto", "@com_google_googleapis//google/iam/v1:iam_java_proto", "@com_google_googleapis//google/identity/accesscontextmanager/v1:accesscontextmanager_proto", ], @@ -61,18 +61,18 @@ java_gapic_library( java_gapic_test( name = "asset_java_gapic_test_suite", test_classes = [ - "com.google.cloud.asset.v1.AssetServiceClientTest", + "com.google.cloud.asset.v1beta1.AssetServiceClientTest", ], runtime_deps = [":asset_java_gapic_test"], ) java_gapic_assembly_gradle_pkg( - name = "google-cloud-asset-v1-java", + name = "google-cloud-asset-v1beta1-java", deps = [ ":asset_java_gapic", - "@com_google_googleapis//google/cloud/asset/v1:asset_java_grpc", - "@com_google_googleapis//google/cloud/asset/v1:asset_java_proto", - "@com_google_googleapis//google/cloud/asset/v1:asset_proto", + "@com_google_googleapis//google/cloud/asset/v1beta1:asset_java_grpc", + "@com_google_googleapis//google/cloud/asset/v1beta1:asset_java_proto", + "@com_google_googleapis//google/cloud/asset/v1beta1:asset_proto", "@com_google_googleapis//google/cloud/orgpolicy/v1:orgpolicy_java_proto", "@com_google_googleapis//google/identity/accesscontextmanager/v1:accesscontextmanager_java_proto", ], diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index cfce3edd87..17d5c02974 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -14,28 +14,18 @@ * limitations under the License. */ -package com.google.cloud.asset.v1; +package com.google.cloud.asset.v1beta1; -import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; -import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.longrunning.OperationFuture; -import com.google.api.gax.paging.AbstractFixedSizeCollection; -import com.google.api.gax.paging.AbstractPage; -import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.OperationCallable; -import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.asset.v1.stub.AssetServiceStub; -import com.google.cloud.asset.v1.stub.AssetServiceStubSettings; -import com.google.common.util.concurrent.MoreExecutors; +import com.google.cloud.asset.v1beta1.stub.AssetServiceStub; +import com.google.cloud.asset.v1beta1.stub.AssetServiceStubSettings; import com.google.longrunning.Operation; import com.google.longrunning.OperationsClient; -import com.google.protobuf.Empty; import java.io.IOException; -import java.util.List; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -93,7 +83,7 @@ *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class AssetServiceClient implements BackgroundResource { private final AssetServiceSettings settings; private final AssetServiceStub stub; @@ -158,14 +148,10 @@ public final OperationsClient getOperationsClient() { // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. - * For Cloud Storage location destinations, the output format is newline-delimited JSON. Each line - * represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for - * BigQuery table destinations, the output table stores the fields in asset proto as columns. This - * API implements the [google.longrunning.Operation][google.longrunning.Operation] API , which - * allows you to keep track of the export. We recommend intervals of at least 2 seconds with - * exponential retry to poll the export operation result. For regular-size resource parent, the - * export operation usually finishes within 5 minutes. + * Exports assets with time and resource types to a given Cloud Storage location. The output + * format is newline-delimited JSON. This API implements the + * [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of + * the export. * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -177,14 +163,10 @@ public final OperationFuture exportAs // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. - * For Cloud Storage location destinations, the output format is newline-delimited JSON. Each line - * represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for - * BigQuery table destinations, the output table stores the fields in asset proto as columns. This - * API implements the [google.longrunning.Operation][google.longrunning.Operation] API , which - * allows you to keep track of the export. We recommend intervals of at least 2 seconds with - * exponential retry to poll the export operation result. For regular-size resource parent, the - * export operation usually finishes within 5 minutes. + * Exports assets with time and resource types to a given Cloud Storage location. The output + * format is newline-delimited JSON. This API implements the + * [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of + * the export. * *

Sample code: */ @@ -195,14 +177,10 @@ public final OperationFuture exportAs // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. - * For Cloud Storage location destinations, the output format is newline-delimited JSON. Each line - * represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for - * BigQuery table destinations, the output table stores the fields in asset proto as columns. This - * API implements the [google.longrunning.Operation][google.longrunning.Operation] API , which - * allows you to keep track of the export. We recommend intervals of at least 2 seconds with - * exponential retry to poll the export operation result. For regular-size resource parent, the - * export operation usually finishes within 5 minutes. + * Exports assets with time and resource types to a given Cloud Storage location. The output + * format is newline-delimited JSON. This API implements the + * [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of + * the export. * *

Sample code: */ @@ -212,11 +190,11 @@ public final UnaryCallable exportAssetsCallable( // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Batch gets the update history of assets that overlap a time window. For IAM_POLICY content, + * Batch gets the update history of assets that overlap a time window. For RESOURCE content, this + * API outputs history with asset in both non-delete or deleted status. For IAM_POLICY content, * this API outputs history when the asset and its attached IAM POLICY both exist. This can create - * gaps in the output history. Otherwise, this API outputs history with asset in both non-delete - * or deleted status. If a specified asset does not exist, this API returns an INVALID_ARGUMENT - * error. + * gaps in the output history. If a specified asset does not exist, this API returns an + * INVALID_ARGUMENT error. * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -228,11 +206,11 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Batch gets the update history of assets that overlap a time window. For IAM_POLICY content, + * Batch gets the update history of assets that overlap a time window. For RESOURCE content, this + * API outputs history with asset in both non-delete or deleted status. For IAM_POLICY content, * this API outputs history when the asset and its attached IAM POLICY both exist. This can create - * gaps in the output history. Otherwise, this API outputs history with asset in both non-delete - * or deleted status. If a specified asset does not exist, this API returns an INVALID_ARGUMENT - * error. + * gaps in the output history. If a specified asset does not exist, this API returns an + * INVALID_ARGUMENT error. * *

Sample code: */ @@ -241,408 +219,6 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( return stub.batchGetAssetsHistoryCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a feed in a parent project/folder/organization to listen to its asset updates. - * - * @param parent Required. The name of the project/folder/organization where this feed should be - * created in. It can only be an organization number (such as "organizations/123"), a folder - * number (such as "folders/123"), a project ID (such as "projects/my-project-id")", or a - * project number (such as "projects/12345"). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Feed createFeed(String parent) { - CreateFeedRequest request = CreateFeedRequest.newBuilder().setParent(parent).build(); - return createFeed(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a feed in a parent project/folder/organization to listen to its asset updates. - * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Feed createFeed(CreateFeedRequest request) { - return createFeedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Creates a feed in a parent project/folder/organization to listen to its asset updates. - * - *

Sample code: - */ - public final UnaryCallable createFeedCallable() { - return stub.createFeedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets details about an asset feed. - * - * @param name Required. The name of the Feed and it must be in the format of: - * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id - * organizations/organization_number/feeds/feed_id - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Feed getFeed(FeedName name) { - GetFeedRequest request = - GetFeedRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return getFeed(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets details about an asset feed. - * - * @param name Required. The name of the Feed and it must be in the format of: - * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id - * organizations/organization_number/feeds/feed_id - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Feed getFeed(String name) { - GetFeedRequest request = GetFeedRequest.newBuilder().setName(name).build(); - return getFeed(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets details about an asset feed. - * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Feed getFeed(GetFeedRequest request) { - return getFeedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Gets details about an asset feed. - * - *

Sample code: - */ - public final UnaryCallable getFeedCallable() { - return stub.getFeedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists all asset feeds in a parent project/folder/organization. - * - * @param parent Required. The parent project/folder/organization whose feeds are to be listed. It - * can only be using project/folder/organization number (such as "folders/12345")", or a - * project ID (such as "projects/my-project-id"). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListFeedsResponse listFeeds(String parent) { - ListFeedsRequest request = ListFeedsRequest.newBuilder().setParent(parent).build(); - return listFeeds(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists all asset feeds in a parent project/folder/organization. - * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final ListFeedsResponse listFeeds(ListFeedsRequest request) { - return listFeedsCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Lists all asset feeds in a parent project/folder/organization. - * - *

Sample code: - */ - public final UnaryCallable listFeedsCallable() { - return stub.listFeedsCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates an asset feed configuration. - * - * @param feed Required. The new values of feed details. It must match an existing feed and the - * field `name` must be in the format of: projects/project_number/feeds/feed_id or - * folders/folder_number/feeds/feed_id or organizations/organization_number/feeds/feed_id. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Feed updateFeed(Feed feed) { - UpdateFeedRequest request = UpdateFeedRequest.newBuilder().setFeed(feed).build(); - return updateFeed(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates an asset feed configuration. - * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final Feed updateFeed(UpdateFeedRequest request) { - return updateFeedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Updates an asset feed configuration. - * - *

Sample code: - */ - public final UnaryCallable updateFeedCallable() { - return stub.updateFeedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes an asset feed. - * - * @param name Required. The name of the feed and it must be in the format of: - * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id - * organizations/organization_number/feeds/feed_id - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteFeed(FeedName name) { - DeleteFeedRequest request = - DeleteFeedRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - deleteFeed(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes an asset feed. - * - * @param name Required. The name of the feed and it must be in the format of: - * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id - * organizations/organization_number/feeds/feed_id - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteFeed(String name) { - DeleteFeedRequest request = DeleteFeedRequest.newBuilder().setName(name).build(); - deleteFeed(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes an asset feed. - * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteFeed(DeleteFeedRequest request) { - deleteFeedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes an asset feed. - * - *

Sample code: - */ - public final UnaryCallable deleteFeedCallable() { - return stub.deleteFeedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Searches all Cloud resources within the specified scope, such as a project, folder, or - * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission - * on the desired scope, otherwise the request will be rejected. - * - * @param scope Required. A scope can be a project, a folder, or an organization. The search is - * limited to the resources within the `scope`. The caller must be granted the - * [`cloudasset.assets.searchAllResources`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) - * permission on the desired scope. - *

The allowed values are: - *

    - *
  • projects/{PROJECT_ID} (e.g., "projects/foo-bar") - *
  • projects/{PROJECT_NUMBER} (e.g., "projects/12345678") - *
  • folders/{FOLDER_NUMBER} (e.g., "folders/1234567") - *
  • organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456") - *
- * - * @param query Optional. The query statement. See [how to construct a - * query](http://cloud.google.com/asset-inventory/docs/searching-resources#how_to_construct_a_query) - * for more information. If not specified or empty, it will search all the resources within - * the specified `scope`. Note that the query string is compared against each Cloud IAM policy - * binding, including its members, roles, and Cloud IAM conditions. The returned Cloud IAM - * policies will only contain the bindings that match your query. To learn more about the IAM - * policy structure, see [IAM policy - * doc](https://cloud.google.com/iam/docs/policies#structure). - *

Examples: - *

    - *
  • `name:Important` to find Cloud resources whose name contains "Important" as a word. - *
  • `displayName:Impor*` to find Cloud resources whose display name contains "Impor" - * as a prefix. - *
  • `description:*por*` to find Cloud resources whose description contains "por" - * as a substring. - *
  • `location:us-west*` to find Cloud resources whose location is prefixed with - * "us-west". - *
  • `labels:prod` to find Cloud resources whose labels contain "prod" as a key or value. - *
  • `labels.env:prod` to find Cloud resources that have a label "env" and its value is - * "prod". - *
  • `labels.env:*` to find Cloud resources that have a label "env". - *
  • `Important` to find Cloud resources that contain "Important" as a word in any of the - * searchable fields. - *
  • `Impor*` to find Cloud resources that contain "Impor" as a prefix in any of the - * searchable fields. - *
  • `*por*` to find Cloud resources that contain "por" as a substring in any of - * the searchable fields. - *
  • `Important location:(us-west1 OR global)` to find Cloud resources that contain - * "Important" as a word in any of the searchable fields and are also located in the - * "us-west1" region or the "global" location. - *
- * - * @param assetTypes Optional. A list of asset types that this request searches for. If empty, it - * will search all the [searchable asset - * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types). - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SearchAllResourcesPagedResponse searchAllResources( - String scope, String query, List assetTypes) { - SearchAllResourcesRequest request = - SearchAllResourcesRequest.newBuilder() - .setScope(scope) - .setQuery(query) - .addAllAssetTypes(assetTypes) - .build(); - return searchAllResources(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Searches all Cloud resources within the specified scope, such as a project, folder, or - * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission - * on the desired scope, otherwise the request will be rejected. - * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SearchAllResourcesPagedResponse searchAllResources( - SearchAllResourcesRequest request) { - return searchAllResourcesPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Searches all Cloud resources within the specified scope, such as a project, folder, or - * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission - * on the desired scope, otherwise the request will be rejected. - * - *

Sample code: - */ - public final UnaryCallable - searchAllResourcesPagedCallable() { - return stub.searchAllResourcesPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Searches all Cloud resources within the specified scope, such as a project, folder, or - * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission - * on the desired scope, otherwise the request will be rejected. - * - *

Sample code: - */ - public final UnaryCallable - searchAllResourcesCallable() { - return stub.searchAllResourcesCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Searches all IAM policies within the specified scope, such as a project, folder, or - * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` - * permission on the desired scope, otherwise the request will be rejected. - * - * @param scope Required. A scope can be a project, a folder, or an organization. The search is - * limited to the IAM policies within the `scope`. The caller must be granted the - * [`cloudasset.assets.searchAllIamPolicies`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) - * permission on the desired scope. - *

The allowed values are: - *

    - *
  • projects/{PROJECT_ID} (e.g., "projects/foo-bar") - *
  • projects/{PROJECT_NUMBER} (e.g., "projects/12345678") - *
  • folders/{FOLDER_NUMBER} (e.g., "folders/1234567") - *
  • organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456") - *
- * - * @param query Optional. The query statement. See [how to construct a - * query](https://cloud.google.com/asset-inventory/docs/searching-iam-policies#how_to_construct_a_query) - * for more information. If not specified or empty, it will search all the IAM policies within - * the specified `scope`. - *

Examples: - *

    - *
  • `policy:amy{@literal @}gmail.com` to find IAM policy bindings that specify user - * "amy{@literal @}gmail.com". - *
  • `policy:roles/compute.admin` to find IAM policy bindings that specify the Compute - * Admin role. - *
  • `policy.role.permissions:storage.buckets.update` to find IAM policy bindings that - * specify a role containing "storage.buckets.update" permission. Note that if callers - * don't have `iam.roles.get` access to a role's included permissions, policy bindings - * that specify this role will be dropped from the search results. - *
  • `resource:organizations/123456` to find IAM policy bindings that are set on - * "organizations/123456". - *
  • `Important` to find IAM policy bindings that contain "Important" as a word in any of - * the searchable fields (except for the included permissions). - *
  • `*por*` to find IAM policy bindings that contain "por" as a substring in any - * of the searchable fields (except for the included permissions). - *
  • `resource:(instance1 OR instance2) policy:amy` to find IAM policy bindings that are - * set on resources "instance1" or "instance2" and also specify user "amy". - *
- * - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope, String query) { - SearchAllIamPoliciesRequest request = - SearchAllIamPoliciesRequest.newBuilder().setScope(scope).setQuery(query).build(); - return searchAllIamPolicies(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Searches all IAM policies within the specified scope, such as a project, folder, or - * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` - * permission on the desired scope, otherwise the request will be rejected. - * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies( - SearchAllIamPoliciesRequest request) { - return searchAllIamPoliciesPagedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Searches all IAM policies within the specified scope, such as a project, folder, or - * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` - * permission on the desired scope, otherwise the request will be rejected. - * - *

Sample code: - */ - public final UnaryCallable - searchAllIamPoliciesPagedCallable() { - return stub.searchAllIamPoliciesPagedCallable(); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Searches all IAM policies within the specified scope, such as a project, folder, or - * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` - * permission on the desired scope, otherwise the request will be rejected. - * - *

Sample code: - */ - public final UnaryCallable - searchAllIamPoliciesCallable() { - return stub.searchAllIamPoliciesCallable(); - } - @Override public final void close() { stub.close(); @@ -672,186 +248,4 @@ public void shutdownNow() { public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { return stub.awaitTermination(duration, unit); } - - public static class SearchAllResourcesPagedResponse - extends AbstractPagedListResponse< - SearchAllResourcesRequest, - SearchAllResourcesResponse, - ResourceSearchResult, - SearchAllResourcesPage, - SearchAllResourcesFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext - context, - ApiFuture futureResponse) { - ApiFuture futurePage = - SearchAllResourcesPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public SearchAllResourcesPagedResponse apply(SearchAllResourcesPage input) { - return new SearchAllResourcesPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private SearchAllResourcesPagedResponse(SearchAllResourcesPage page) { - super(page, SearchAllResourcesFixedSizeCollection.createEmptyCollection()); - } - } - - public static class SearchAllResourcesPage - extends AbstractPage< - SearchAllResourcesRequest, - SearchAllResourcesResponse, - ResourceSearchResult, - SearchAllResourcesPage> { - - private SearchAllResourcesPage( - PageContext - context, - SearchAllResourcesResponse response) { - super(context, response); - } - - private static SearchAllResourcesPage createEmptyPage() { - return new SearchAllResourcesPage(null, null); - } - - @Override - protected SearchAllResourcesPage createPage( - PageContext - context, - SearchAllResourcesResponse response) { - return new SearchAllResourcesPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext - context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class SearchAllResourcesFixedSizeCollection - extends AbstractFixedSizeCollection< - SearchAllResourcesRequest, - SearchAllResourcesResponse, - ResourceSearchResult, - SearchAllResourcesPage, - SearchAllResourcesFixedSizeCollection> { - - private SearchAllResourcesFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static SearchAllResourcesFixedSizeCollection createEmptyCollection() { - return new SearchAllResourcesFixedSizeCollection(null, 0); - } - - @Override - protected SearchAllResourcesFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new SearchAllResourcesFixedSizeCollection(pages, collectionSize); - } - } - - public static class SearchAllIamPoliciesPagedResponse - extends AbstractPagedListResponse< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - IamPolicySearchResult, - SearchAllIamPoliciesPage, - SearchAllIamPoliciesFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext< - SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> - context, - ApiFuture futureResponse) { - ApiFuture futurePage = - SearchAllIamPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - new ApiFunction() { - @Override - public SearchAllIamPoliciesPagedResponse apply(SearchAllIamPoliciesPage input) { - return new SearchAllIamPoliciesPagedResponse(input); - } - }, - MoreExecutors.directExecutor()); - } - - private SearchAllIamPoliciesPagedResponse(SearchAllIamPoliciesPage page) { - super(page, SearchAllIamPoliciesFixedSizeCollection.createEmptyCollection()); - } - } - - public static class SearchAllIamPoliciesPage - extends AbstractPage< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - IamPolicySearchResult, - SearchAllIamPoliciesPage> { - - private SearchAllIamPoliciesPage( - PageContext< - SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> - context, - SearchAllIamPoliciesResponse response) { - super(context, response); - } - - private static SearchAllIamPoliciesPage createEmptyPage() { - return new SearchAllIamPoliciesPage(null, null); - } - - @Override - protected SearchAllIamPoliciesPage createPage( - PageContext< - SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> - context, - SearchAllIamPoliciesResponse response) { - return new SearchAllIamPoliciesPage(context, response); - } - - @Override - public ApiFuture createPageAsync( - PageContext< - SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> - context, - ApiFuture futureResponse) { - return super.createPageAsync(context, futureResponse); - } - } - - public static class SearchAllIamPoliciesFixedSizeCollection - extends AbstractFixedSizeCollection< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - IamPolicySearchResult, - SearchAllIamPoliciesPage, - SearchAllIamPoliciesFixedSizeCollection> { - - private SearchAllIamPoliciesFixedSizeCollection( - List pages, int collectionSize) { - super(pages, collectionSize); - } - - private static SearchAllIamPoliciesFixedSizeCollection createEmptyCollection() { - return new SearchAllIamPoliciesFixedSizeCollection(null, 0); - } - - @Override - protected SearchAllIamPoliciesFixedSizeCollection createCollection( - List pages, int collectionSize) { - return new SearchAllIamPoliciesFixedSizeCollection(pages, collectionSize); - } - } } diff --git a/test/integration/goldens/asset/AssetServiceClientTest.java b/test/integration/goldens/asset/AssetServiceClientTest.java index f12688c9d7..2bcb165008 100644 --- a/test/integration/goldens/asset/AssetServiceClientTest.java +++ b/test/integration/goldens/asset/AssetServiceClientTest.java @@ -14,10 +14,7 @@ * limitations under the License. */ -package com.google.cloud.asset.v1; - -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; +package com.google.cloud.asset.v1beta1; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GaxGrpcProperties; @@ -27,13 +24,10 @@ import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.InvalidArgumentException; import com.google.api.gax.rpc.StatusCode; -import com.google.common.collect.Lists; import com.google.longrunning.Operation; import com.google.protobuf.AbstractMessage; import com.google.protobuf.Any; -import com.google.protobuf.Empty; import com.google.protobuf.Timestamp; -import com.google.type.Expr; import io.grpc.StatusRuntimeException; import java.io.IOException; import java.util.ArrayList; @@ -93,7 +87,6 @@ public void exportAssetsTest() throws Exception { ExportAssetsResponse.newBuilder() .setReadTime(Timestamp.newBuilder().build()) .setOutputConfig(OutputConfig.newBuilder().build()) - .setOutputResult(OutputResult.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -105,7 +98,7 @@ public void exportAssetsTest() throws Exception { ExportAssetsRequest request = ExportAssetsRequest.newBuilder() - .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) + .setParent("ExportAssetsRequest-846449128".toString()) .setReadTime(Timestamp.newBuilder().build()) .addAllAssetTypes(new ArrayList()) .setOutputConfig(OutputConfig.newBuilder().build()) @@ -137,7 +130,7 @@ public void exportAssetsExceptionTest() throws Exception { try { ExportAssetsRequest request = ExportAssetsRequest.newBuilder() - .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) + .setParent("ExportAssetsRequest-846449128".toString()) .setReadTime(Timestamp.newBuilder().build()) .addAllAssetTypes(new ArrayList()) .setOutputConfig(OutputConfig.newBuilder().build()) @@ -161,7 +154,7 @@ public void batchGetAssetsHistoryTest() throws Exception { BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder() - .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) + .setParent("BatchGetAssetsHistoryRequest1575208378".toString()) .addAllAssetNames(new ArrayList()) .setReadTimeWindow(TimeWindow.newBuilder().build()) .build(); @@ -192,7 +185,7 @@ public void batchGetAssetsHistoryExceptionTest() throws Exception { try { BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder() - .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) + .setParent("BatchGetAssetsHistoryRequest1575208378".toString()) .addAllAssetNames(new ArrayList()) .setReadTimeWindow(TimeWindow.newBuilder().build()) .build(); @@ -202,375 +195,4 @@ public void batchGetAssetsHistoryExceptionTest() throws Exception { // Expected exception. } } - - @Test - public void createFeedTest() throws Exception { - Feed expectedResponse = - Feed.newBuilder() - .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) - .addAllAssetNames(new ArrayList()) - .addAllAssetTypes(new ArrayList()) - .setFeedOutputConfig(FeedOutputConfig.newBuilder().build()) - .setCondition(Expr.newBuilder().build()) - .build(); - mockAssetService.addResponse(expectedResponse); - - String parent = "parent-995424086"; - - Feed actualResponse = client.createFeed(parent); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - CreateFeedRequest actualRequest = ((CreateFeedRequest) actualRequests.get(0)); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void createFeedExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - String parent = "parent-995424086"; - client.createFeed(parent); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void getFeedTest() throws Exception { - Feed expectedResponse = - Feed.newBuilder() - .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) - .addAllAssetNames(new ArrayList()) - .addAllAssetTypes(new ArrayList()) - .setFeedOutputConfig(FeedOutputConfig.newBuilder().build()) - .setCondition(Expr.newBuilder().build()) - .build(); - mockAssetService.addResponse(expectedResponse); - - FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); - - Feed actualResponse = client.getFeed(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetFeedRequest actualRequest = ((GetFeedRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getFeedExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); - client.getFeed(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void getFeedTest2() throws Exception { - Feed expectedResponse = - Feed.newBuilder() - .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) - .addAllAssetNames(new ArrayList()) - .addAllAssetTypes(new ArrayList()) - .setFeedOutputConfig(FeedOutputConfig.newBuilder().build()) - .setCondition(Expr.newBuilder().build()) - .build(); - mockAssetService.addResponse(expectedResponse); - - String name = "name3373707"; - - Feed actualResponse = client.getFeed(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetFeedRequest actualRequest = ((GetFeedRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getFeedExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - String name = "name3373707"; - client.getFeed(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void listFeedsTest() throws Exception { - ListFeedsResponse expectedResponse = - ListFeedsResponse.newBuilder().addAllFeeds(new ArrayList()).build(); - mockAssetService.addResponse(expectedResponse); - - String parent = "parent-995424086"; - - ListFeedsResponse actualResponse = client.listFeeds(parent); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - ListFeedsRequest actualRequest = ((ListFeedsRequest) actualRequests.get(0)); - - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void listFeedsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - String parent = "parent-995424086"; - client.listFeeds(parent); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void updateFeedTest() throws Exception { - Feed expectedResponse = - Feed.newBuilder() - .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) - .addAllAssetNames(new ArrayList()) - .addAllAssetTypes(new ArrayList()) - .setFeedOutputConfig(FeedOutputConfig.newBuilder().build()) - .setCondition(Expr.newBuilder().build()) - .build(); - mockAssetService.addResponse(expectedResponse); - - Feed feed = Feed.newBuilder().build(); - - Feed actualResponse = client.updateFeed(feed); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - UpdateFeedRequest actualRequest = ((UpdateFeedRequest) actualRequests.get(0)); - - Assert.assertEquals(feed, actualRequest.getFeed()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void updateFeedExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - Feed feed = Feed.newBuilder().build(); - client.updateFeed(feed); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void deleteFeedTest() throws Exception { - Empty expectedResponse = Empty.newBuilder().build(); - mockAssetService.addResponse(expectedResponse); - - FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); - - client.deleteFeed(name); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteFeedRequest actualRequest = ((DeleteFeedRequest) actualRequests.get(0)); - - Assert.assertEquals(name.toString(), actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void deleteFeedExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); - client.deleteFeed(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void deleteFeedTest2() throws Exception { - Empty expectedResponse = Empty.newBuilder().build(); - mockAssetService.addResponse(expectedResponse); - - String name = "name3373707"; - - client.deleteFeed(name); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteFeedRequest actualRequest = ((DeleteFeedRequest) actualRequests.get(0)); - - Assert.assertEquals(name, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void deleteFeedExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - String name = "name3373707"; - client.deleteFeed(name); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void searchAllResourcesTest() throws Exception { - ResourceSearchResult responsesElement = ResourceSearchResult.newBuilder().build(); - SearchAllResourcesResponse expectedResponse = - SearchAllResourcesResponse.newBuilder() - .setNextPageToken("") - .addAllResults(Arrays.asList(responsesElement)) - .build(); - mockAssetService.addResponse(expectedResponse); - - String scope = "scope109264468"; - String query = "query107944136"; - List assetTypes = new ArrayList<>(); - - SearchAllResourcesPagedResponse pagedListResponse = - client.searchAllResources(scope, query, assetTypes); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SearchAllResourcesRequest actualRequest = ((SearchAllResourcesRequest) actualRequests.get(0)); - - Assert.assertEquals(scope, actualRequest.getScope()); - Assert.assertEquals(query, actualRequest.getQuery()); - Assert.assertEquals(assetTypes, actualRequest.getAssetTypesList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void searchAllResourcesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - String scope = "scope109264468"; - String query = "query107944136"; - List assetTypes = new ArrayList<>(); - client.searchAllResources(scope, query, assetTypes); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void searchAllIamPoliciesTest() throws Exception { - IamPolicySearchResult responsesElement = IamPolicySearchResult.newBuilder().build(); - SearchAllIamPoliciesResponse expectedResponse = - SearchAllIamPoliciesResponse.newBuilder() - .setNextPageToken("") - .addAllResults(Arrays.asList(responsesElement)) - .build(); - mockAssetService.addResponse(expectedResponse); - - String scope = "scope109264468"; - String query = "query107944136"; - - SearchAllIamPoliciesPagedResponse pagedListResponse = client.searchAllIamPolicies(scope, query); - - List resources = Lists.newArrayList(pagedListResponse.iterateAll()); - - Assert.assertEquals(1, resources.size()); - Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SearchAllIamPoliciesRequest actualRequest = - ((SearchAllIamPoliciesRequest) actualRequests.get(0)); - - Assert.assertEquals(scope, actualRequest.getScope()); - Assert.assertEquals(query, actualRequest.getQuery()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void searchAllIamPoliciesExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - String scope = "scope109264468"; - String query = "query107944136"; - client.searchAllIamPolicies(scope, query); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } } diff --git a/test/integration/goldens/asset/AssetServiceSettings.java b/test/integration/goldens/asset/AssetServiceSettings.java index be010b730a..3b6c7817dd 100644 --- a/test/integration/goldens/asset/AssetServiceSettings.java +++ b/test/integration/goldens/asset/AssetServiceSettings.java @@ -14,10 +14,7 @@ * limitations under the License. */ -package com.google.cloud.asset.v1; - -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; +package com.google.cloud.asset.v1beta1; import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; @@ -28,13 +25,11 @@ import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.PagedCallSettings; import com.google.api.gax.rpc.StubSettings; import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.asset.v1.stub.AssetServiceStubSettings; +import com.google.cloud.asset.v1beta1.stub.AssetServiceStubSettings; import com.google.longrunning.Operation; -import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; import javax.annotation.Generated; @@ -70,6 +65,7 @@ * AssetServiceSettings assetServiceSettings = assetServiceSettingsBuilder.build(); * } */ +@BetaApi @Generated("by gapic-generator-java") public class AssetServiceSettings extends ClientSettings { @@ -90,47 +86,6 @@ public UnaryCallSettings exportAssetsSettings() return ((AssetServiceStubSettings) getStubSettings()).batchGetAssetsHistorySettings(); } - /** Returns the object with the settings used for calls to createFeed. */ - public UnaryCallSettings createFeedSettings() { - return ((AssetServiceStubSettings) getStubSettings()).createFeedSettings(); - } - - /** Returns the object with the settings used for calls to getFeed. */ - public UnaryCallSettings getFeedSettings() { - return ((AssetServiceStubSettings) getStubSettings()).getFeedSettings(); - } - - /** Returns the object with the settings used for calls to listFeeds. */ - public UnaryCallSettings listFeedsSettings() { - return ((AssetServiceStubSettings) getStubSettings()).listFeedsSettings(); - } - - /** Returns the object with the settings used for calls to updateFeed. */ - public UnaryCallSettings updateFeedSettings() { - return ((AssetServiceStubSettings) getStubSettings()).updateFeedSettings(); - } - - /** Returns the object with the settings used for calls to deleteFeed. */ - public UnaryCallSettings deleteFeedSettings() { - return ((AssetServiceStubSettings) getStubSettings()).deleteFeedSettings(); - } - - /** Returns the object with the settings used for calls to searchAllResources. */ - public PagedCallSettings< - SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> - searchAllResourcesSettings() { - return ((AssetServiceStubSettings) getStubSettings()).searchAllResourcesSettings(); - } - - /** Returns the object with the settings used for calls to searchAllIamPolicies. */ - public PagedCallSettings< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - SearchAllIamPoliciesPagedResponse> - searchAllIamPoliciesSettings() { - return ((AssetServiceStubSettings) getStubSettings()).searchAllIamPoliciesSettings(); - } - public static final AssetServiceSettings create(AssetServiceStubSettings stub) throws IOException { return new AssetServiceSettings.Builder(stub.toBuilder()).build(); @@ -247,47 +202,6 @@ public UnaryCallSettings.Builder exportAssetsSet return getStubSettingsBuilder().batchGetAssetsHistorySettings(); } - /** Returns the builder for the settings used for calls to createFeed. */ - public UnaryCallSettings.Builder createFeedSettings() { - return getStubSettingsBuilder().createFeedSettings(); - } - - /** Returns the builder for the settings used for calls to getFeed. */ - public UnaryCallSettings.Builder getFeedSettings() { - return getStubSettingsBuilder().getFeedSettings(); - } - - /** Returns the builder for the settings used for calls to listFeeds. */ - public UnaryCallSettings.Builder listFeedsSettings() { - return getStubSettingsBuilder().listFeedsSettings(); - } - - /** Returns the builder for the settings used for calls to updateFeed. */ - public UnaryCallSettings.Builder updateFeedSettings() { - return getStubSettingsBuilder().updateFeedSettings(); - } - - /** Returns the builder for the settings used for calls to deleteFeed. */ - public UnaryCallSettings.Builder deleteFeedSettings() { - return getStubSettingsBuilder().deleteFeedSettings(); - } - - /** Returns the builder for the settings used for calls to searchAllResources. */ - public PagedCallSettings.Builder< - SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> - searchAllResourcesSettings() { - return getStubSettingsBuilder().searchAllResourcesSettings(); - } - - /** Returns the builder for the settings used for calls to searchAllIamPolicies. */ - public PagedCallSettings.Builder< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - SearchAllIamPoliciesPagedResponse> - searchAllIamPoliciesSettings() { - return getStubSettingsBuilder().searchAllIamPoliciesSettings(); - } - @Override public AssetServiceSettings build() throws IOException { return new AssetServiceSettings(this); diff --git a/test/integration/goldens/asset/AssetServiceStub.java b/test/integration/goldens/asset/AssetServiceStub.java index 81eda8b2cd..27dc91eb21 100644 --- a/test/integration/goldens/asset/AssetServiceStub.java +++ b/test/integration/goldens/asset/AssetServiceStub.java @@ -14,32 +14,18 @@ * limitations under the License. */ -package com.google.cloud.asset.v1.stub; - -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; +package com.google.cloud.asset.v1beta1.stub; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest; -import com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse; -import com.google.cloud.asset.v1.CreateFeedRequest; -import com.google.cloud.asset.v1.DeleteFeedRequest; -import com.google.cloud.asset.v1.ExportAssetsRequest; -import com.google.cloud.asset.v1.ExportAssetsResponse; -import com.google.cloud.asset.v1.Feed; -import com.google.cloud.asset.v1.GetFeedRequest; -import com.google.cloud.asset.v1.ListFeedsRequest; -import com.google.cloud.asset.v1.ListFeedsResponse; -import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest; -import com.google.cloud.asset.v1.SearchAllIamPoliciesResponse; -import com.google.cloud.asset.v1.SearchAllResourcesRequest; -import com.google.cloud.asset.v1.SearchAllResourcesResponse; -import com.google.cloud.asset.v1.UpdateFeedRequest; +import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryRequest; +import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryResponse; +import com.google.cloud.asset.v1beta1.ExportAssetsRequest; +import com.google.cloud.asset.v1beta1.ExportAssetsResponse; import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; -import com.google.protobuf.Empty; import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS. @@ -48,7 +34,8 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public abstract class AssetServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { @@ -69,46 +56,6 @@ public UnaryCallable exportAssetsCallable() { throw new UnsupportedOperationException("Not implemented: batchGetAssetsHistoryCallable()"); } - public UnaryCallable createFeedCallable() { - throw new UnsupportedOperationException("Not implemented: createFeedCallable()"); - } - - public UnaryCallable getFeedCallable() { - throw new UnsupportedOperationException("Not implemented: getFeedCallable()"); - } - - public UnaryCallable listFeedsCallable() { - throw new UnsupportedOperationException("Not implemented: listFeedsCallable()"); - } - - public UnaryCallable updateFeedCallable() { - throw new UnsupportedOperationException("Not implemented: updateFeedCallable()"); - } - - public UnaryCallable deleteFeedCallable() { - throw new UnsupportedOperationException("Not implemented: deleteFeedCallable()"); - } - - public UnaryCallable - searchAllResourcesPagedCallable() { - throw new UnsupportedOperationException("Not implemented: searchAllResourcesPagedCallable()"); - } - - public UnaryCallable - searchAllResourcesCallable() { - throw new UnsupportedOperationException("Not implemented: searchAllResourcesCallable()"); - } - - public UnaryCallable - searchAllIamPoliciesPagedCallable() { - throw new UnsupportedOperationException("Not implemented: searchAllIamPoliciesPagedCallable()"); - } - - public UnaryCallable - searchAllIamPoliciesCallable() { - throw new UnsupportedOperationException("Not implemented: searchAllIamPoliciesCallable()"); - } - @Override public abstract void close(); } diff --git a/test/integration/goldens/asset/AssetServiceStubSettings.java b/test/integration/goldens/asset/AssetServiceStubSettings.java index 055e09dea5..79c8b3191e 100644 --- a/test/integration/goldens/asset/AssetServiceStubSettings.java +++ b/test/integration/goldens/asset/AssetServiceStubSettings.java @@ -14,13 +14,9 @@ * limitations under the License. */ -package com.google.cloud.asset.v1.stub; - -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; +package com.google.cloud.asset.v1beta1.stub; import com.google.api.core.ApiFunction; -import com.google.api.core.ApiFuture; import com.google.api.core.BetaApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; @@ -32,42 +28,22 @@ import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; -import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.OperationCallSettings; -import com.google.api.gax.rpc.PageContext; -import com.google.api.gax.rpc.PagedCallSettings; -import com.google.api.gax.rpc.PagedListDescriptor; -import com.google.api.gax.rpc.PagedListResponseFactory; import com.google.api.gax.rpc.StatusCode; import com.google.api.gax.rpc.StubSettings; import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest; -import com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse; -import com.google.cloud.asset.v1.CreateFeedRequest; -import com.google.cloud.asset.v1.DeleteFeedRequest; -import com.google.cloud.asset.v1.ExportAssetsRequest; -import com.google.cloud.asset.v1.ExportAssetsResponse; -import com.google.cloud.asset.v1.Feed; -import com.google.cloud.asset.v1.GetFeedRequest; -import com.google.cloud.asset.v1.IamPolicySearchResult; -import com.google.cloud.asset.v1.ListFeedsRequest; -import com.google.cloud.asset.v1.ListFeedsResponse; -import com.google.cloud.asset.v1.ResourceSearchResult; -import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest; -import com.google.cloud.asset.v1.SearchAllIamPoliciesResponse; -import com.google.cloud.asset.v1.SearchAllResourcesRequest; -import com.google.cloud.asset.v1.SearchAllResourcesResponse; -import com.google.cloud.asset.v1.UpdateFeedRequest; +import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryRequest; +import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryResponse; +import com.google.cloud.asset.v1beta1.ExportAssetsRequest; +import com.google.cloud.asset.v1beta1.ExportAssetsResponse; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.longrunning.Operation; -import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; import javax.annotation.Generated; @@ -118,149 +94,6 @@ public class AssetServiceStubSettings extends StubSettings batchGetAssetsHistorySettings; - private final UnaryCallSettings createFeedSettings; - private final UnaryCallSettings getFeedSettings; - private final UnaryCallSettings listFeedsSettings; - private final UnaryCallSettings updateFeedSettings; - private final UnaryCallSettings deleteFeedSettings; - private final PagedCallSettings< - SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> - searchAllResourcesSettings; - private final PagedCallSettings< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - SearchAllIamPoliciesPagedResponse> - searchAllIamPoliciesSettings; - - private static final PagedListDescriptor< - SearchAllResourcesRequest, SearchAllResourcesResponse, ResourceSearchResult> - SEARCH_ALL_RESOURCES_PAGE_STR_DESC = - new PagedListDescriptor< - SearchAllResourcesRequest, SearchAllResourcesResponse, ResourceSearchResult>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public SearchAllResourcesRequest injectToken( - SearchAllResourcesRequest payload, String token) { - return SearchAllResourcesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public SearchAllResourcesRequest injectPageSize( - SearchAllResourcesRequest payload, int pageSize) { - return SearchAllResourcesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(SearchAllResourcesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(SearchAllResourcesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources( - SearchAllResourcesResponse payload) { - return payload.getResultsList() == null - ? ImmutableList.of() - : payload.getResultsList(); - } - }; - - private static final PagedListDescriptor< - SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> - SEARCH_ALL_IAM_POLICIES_PAGE_STR_DESC = - new PagedListDescriptor< - SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult>() { - @Override - public String emptyToken() { - return ""; - } - - @Override - public SearchAllIamPoliciesRequest injectToken( - SearchAllIamPoliciesRequest payload, String token) { - return SearchAllIamPoliciesRequest.newBuilder(payload).setPageToken(token).build(); - } - - @Override - public SearchAllIamPoliciesRequest injectPageSize( - SearchAllIamPoliciesRequest payload, int pageSize) { - return SearchAllIamPoliciesRequest.newBuilder(payload).setPageSize(pageSize).build(); - } - - @Override - public Integer extractPageSize(SearchAllIamPoliciesRequest payload) { - return payload.getPageSize(); - } - - @Override - public String extractNextToken(SearchAllIamPoliciesResponse payload) { - return payload.getNextPageToken(); - } - - @Override - public Iterable extractResources( - SearchAllIamPoliciesResponse payload) { - return payload.getResultsList() == null - ? ImmutableList.of() - : payload.getResultsList(); - } - }; - - private static final PagedListResponseFactory< - SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> - SEARCH_ALL_RESOURCES_PAGE_STR_FACT = - new PagedListResponseFactory< - SearchAllResourcesRequest, - SearchAllResourcesResponse, - SearchAllResourcesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - SearchAllResourcesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext< - SearchAllResourcesRequest, SearchAllResourcesResponse, ResourceSearchResult> - pageContext = - PageContext.create( - callable, SEARCH_ALL_RESOURCES_PAGE_STR_DESC, request, context); - return SearchAllResourcesPagedResponse.createAsync(pageContext, futureResponse); - } - }; - - private static final PagedListResponseFactory< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - SearchAllIamPoliciesPagedResponse> - SEARCH_ALL_IAM_POLICIES_PAGE_STR_FACT = - new PagedListResponseFactory< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - SearchAllIamPoliciesPagedResponse>() { - @Override - public ApiFuture getFuturePagedResponse( - UnaryCallable callable, - SearchAllIamPoliciesRequest request, - ApiCallContext context, - ApiFuture futureResponse) { - PageContext< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - IamPolicySearchResult> - pageContext = - PageContext.create( - callable, SEARCH_ALL_IAM_POLICIES_PAGE_STR_DESC, request, context); - return SearchAllIamPoliciesPagedResponse.createAsync(pageContext, futureResponse); - } - }; /** Returns the object with the settings used for calls to exportAssets. */ public UnaryCallSettings exportAssetsSettings() { @@ -279,47 +112,6 @@ public UnaryCallSettings exportAssetsSettings() return batchGetAssetsHistorySettings; } - /** Returns the object with the settings used for calls to createFeed. */ - public UnaryCallSettings createFeedSettings() { - return createFeedSettings; - } - - /** Returns the object with the settings used for calls to getFeed. */ - public UnaryCallSettings getFeedSettings() { - return getFeedSettings; - } - - /** Returns the object with the settings used for calls to listFeeds. */ - public UnaryCallSettings listFeedsSettings() { - return listFeedsSettings; - } - - /** Returns the object with the settings used for calls to updateFeed. */ - public UnaryCallSettings updateFeedSettings() { - return updateFeedSettings; - } - - /** Returns the object with the settings used for calls to deleteFeed. */ - public UnaryCallSettings deleteFeedSettings() { - return deleteFeedSettings; - } - - /** Returns the object with the settings used for calls to searchAllResources. */ - public PagedCallSettings< - SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> - searchAllResourcesSettings() { - return searchAllResourcesSettings; - } - - /** Returns the object with the settings used for calls to searchAllIamPolicies. */ - public PagedCallSettings< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - SearchAllIamPoliciesPagedResponse> - searchAllIamPoliciesSettings() { - return searchAllIamPoliciesSettings; - } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public AssetServiceStub createStub() throws IOException { if (getTransportChannelProvider() @@ -392,13 +184,6 @@ protected AssetServiceStubSettings(Builder settingsBuilder) throws IOException { exportAssetsSettings = settingsBuilder.exportAssetsSettings().build(); exportAssetsOperationSettings = settingsBuilder.exportAssetsOperationSettings().build(); batchGetAssetsHistorySettings = settingsBuilder.batchGetAssetsHistorySettings().build(); - createFeedSettings = settingsBuilder.createFeedSettings().build(); - getFeedSettings = settingsBuilder.getFeedSettings().build(); - listFeedsSettings = settingsBuilder.listFeedsSettings().build(); - updateFeedSettings = settingsBuilder.updateFeedSettings().build(); - deleteFeedSettings = settingsBuilder.deleteFeedSettings().build(); - searchAllResourcesSettings = settingsBuilder.searchAllResourcesSettings().build(); - searchAllIamPoliciesSettings = settingsBuilder.searchAllIamPoliciesSettings().build(); } /** Builder for AssetServiceStubSettings. */ @@ -411,19 +196,6 @@ public static class Builder extends StubSettings.Builder batchGetAssetsHistorySettings; - private final UnaryCallSettings.Builder createFeedSettings; - private final UnaryCallSettings.Builder getFeedSettings; - private final UnaryCallSettings.Builder listFeedsSettings; - private final UnaryCallSettings.Builder updateFeedSettings; - private final UnaryCallSettings.Builder deleteFeedSettings; - private final PagedCallSettings.Builder< - SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> - searchAllResourcesSettings; - private final PagedCallSettings.Builder< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - SearchAllIamPoliciesPagedResponse> - searchAllIamPoliciesSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -437,11 +209,6 @@ public static class Builder extends StubSettings.BuildernewArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); - definitions.put( - "retry_policy_2_codes", - ImmutableSet.copyOf( - Lists.newArrayList( - StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -469,17 +236,6 @@ public static class Builder extends StubSettings.Builder>of( - exportAssetsSettings, - batchGetAssetsHistorySettings, - createFeedSettings, - getFeedSettings, - listFeedsSettings, - updateFeedSettings, - deleteFeedSettings, - searchAllResourcesSettings, - searchAllIamPoliciesSettings); + exportAssetsSettings, batchGetAssetsHistorySettings); initDefaults(this); } @@ -522,25 +262,10 @@ protected Builder(AssetServiceStubSettings settings) { exportAssetsSettings = settings.exportAssetsSettings.toBuilder(); exportAssetsOperationSettings = settings.exportAssetsOperationSettings.toBuilder(); batchGetAssetsHistorySettings = settings.batchGetAssetsHistorySettings.toBuilder(); - createFeedSettings = settings.createFeedSettings.toBuilder(); - getFeedSettings = settings.getFeedSettings.toBuilder(); - listFeedsSettings = settings.listFeedsSettings.toBuilder(); - updateFeedSettings = settings.updateFeedSettings.toBuilder(); - deleteFeedSettings = settings.deleteFeedSettings.toBuilder(); - searchAllResourcesSettings = settings.searchAllResourcesSettings.toBuilder(); - searchAllIamPoliciesSettings = settings.searchAllIamPoliciesSettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( - exportAssetsSettings, - batchGetAssetsHistorySettings, - createFeedSettings, - getFeedSettings, - listFeedsSettings, - updateFeedSettings, - deleteFeedSettings, - searchAllResourcesSettings, - searchAllIamPoliciesSettings); + exportAssetsSettings, batchGetAssetsHistorySettings); } private static Builder createDefault() { @@ -565,41 +290,6 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - builder - .createFeedSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .getFeedSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .listFeedsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .updateFeedSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); - - builder - .deleteFeedSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); - - builder - .searchAllResourcesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); - - builder - .searchAllIamPoliciesSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); - builder .exportAssetsOperationSettings() .setInitialCallSettings( @@ -663,47 +353,6 @@ public UnaryCallSettings.Builder exportAssetsSet return batchGetAssetsHistorySettings; } - /** Returns the builder for the settings used for calls to createFeed. */ - public UnaryCallSettings.Builder createFeedSettings() { - return createFeedSettings; - } - - /** Returns the builder for the settings used for calls to getFeed. */ - public UnaryCallSettings.Builder getFeedSettings() { - return getFeedSettings; - } - - /** Returns the builder for the settings used for calls to listFeeds. */ - public UnaryCallSettings.Builder listFeedsSettings() { - return listFeedsSettings; - } - - /** Returns the builder for the settings used for calls to updateFeed. */ - public UnaryCallSettings.Builder updateFeedSettings() { - return updateFeedSettings; - } - - /** Returns the builder for the settings used for calls to deleteFeed. */ - public UnaryCallSettings.Builder deleteFeedSettings() { - return deleteFeedSettings; - } - - /** Returns the builder for the settings used for calls to searchAllResources. */ - public PagedCallSettings.Builder< - SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> - searchAllResourcesSettings() { - return searchAllResourcesSettings; - } - - /** Returns the builder for the settings used for calls to searchAllIamPolicies. */ - public PagedCallSettings.Builder< - SearchAllIamPoliciesRequest, - SearchAllIamPoliciesResponse, - SearchAllIamPoliciesPagedResponse> - searchAllIamPoliciesSettings() { - return searchAllIamPoliciesSettings; - } - @Override public AssetServiceStubSettings build() throws IOException { return new AssetServiceStubSettings(this); diff --git a/test/integration/goldens/asset/FeedName.java b/test/integration/goldens/asset/FeedName.java deleted file mode 100644 index b9e600c37d..0000000000 --- a/test/integration/goldens/asset/FeedName.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright 2020 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.asset.v1; - -import com.google.api.core.BetaApi; -import com.google.api.pathtemplate.PathTemplate; -import com.google.api.pathtemplate.ValidationException; -import com.google.api.resourcenames.ResourceName; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import javax.annotation.Generated; - -// AUTO-GENERATED DOCUMENTATION AND CLASS. -@Generated("by gapic-generator-java") -public class FeedName implements ResourceName { - private static final PathTemplate PROJECT_FEED = - PathTemplate.createWithoutUrlEncoding("projects/{project}/feeds/{feed}"); - private static final PathTemplate FOLDER_FEED = - PathTemplate.createWithoutUrlEncoding("folders/{folder}/feeds/{feed}"); - private static final PathTemplate ORGANIZATION_FEED = - PathTemplate.createWithoutUrlEncoding("organizations/{organization}/feeds/{feed}"); - private volatile Map fieldValuesMap; - private PathTemplate pathTemplate; - private String fixedValue; - private final String project; - private final String feed; - private final String folder; - private final String organization; - - @Deprecated - protected FeedName() { - project = null; - feed = null; - folder = null; - organization = null; - } - - private FeedName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - feed = Preconditions.checkNotNull(builder.getFeed()); - folder = null; - organization = null; - pathTemplate = PROJECT_FEED; - } - - private FeedName(FolderFeedBuilder builder) { - folder = Preconditions.checkNotNull(builder.getFolder()); - feed = Preconditions.checkNotNull(builder.getFeed()); - project = null; - organization = null; - pathTemplate = FOLDER_FEED; - } - - private FeedName(OrganizationFeedBuilder builder) { - organization = Preconditions.checkNotNull(builder.getOrganization()); - feed = Preconditions.checkNotNull(builder.getFeed()); - project = null; - folder = null; - pathTemplate = ORGANIZATION_FEED; - } - - public String getProject() { - return project; - } - - public String getFeed() { - return feed; - } - - public String getFolder() { - return folder; - } - - public String getOrganization() { - return organization; - } - - public static Builder newBuilder() { - return new Builder(); - } - - @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static Builder newProjectFeedBuilder() { - return new Builder(); - } - - @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static FolderFeedBuilder newFolderFeedBuilder() { - return new FolderFeedBuilder(); - } - - @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static OrganizationFeedBuilder newOrganizationFeedBuilder() { - return new OrganizationFeedBuilder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static FeedName of(String project, String feed) { - return newBuilder().setProject(project).setFeed(feed).build(); - } - - @BetaApi("The static create methods are not stable yet and may be changed in the future.") - public static FeedName ofProjectFeedName(String project, String feed) { - return newBuilder().setProject(project).setFeed(feed).build(); - } - - @BetaApi("The static create methods are not stable yet and may be changed in the future.") - public static FeedName ofFolderFeedName(String folder, String feed) { - return newFolderFeedBuilder().setFolder(folder).setFeed(feed).build(); - } - - @BetaApi("The static create methods are not stable yet and may be changed in the future.") - public static FeedName ofOrganizationFeedName(String organization, String feed) { - return newOrganizationFeedBuilder().setOrganization(organization).setFeed(feed).build(); - } - - public static String format(String project, String feed) { - return newBuilder().setProject(project).setFeed(feed).build().toString(); - } - - @BetaApi("The static format methods are not stable yet and may be changed in the future.") - public static String formatProjectFeedName(String project, String feed) { - return newBuilder().setProject(project).setFeed(feed).build().toString(); - } - - @BetaApi("The static format methods are not stable yet and may be changed in the future.") - public static String formatFolderFeedName(String folder, String feed) { - return newFolderFeedBuilder().setFolder(folder).setFeed(feed).build().toString(); - } - - @BetaApi("The static format methods are not stable yet and may be changed in the future.") - public static String formatOrganizationFeedName(String organization, String feed) { - return newOrganizationFeedBuilder() - .setOrganization(organization) - .setFeed(feed) - .build() - .toString(); - } - - public static FeedName parse(String formattedString) { - if (formattedString.isEmpty()) { - return null; - } - if (PROJECT_FEED.matches(formattedString)) { - Map matchMap = PROJECT_FEED.match(formattedString); - return ofProjectFeedName(matchMap.get("project"), matchMap.get("feed")); - } else if (FOLDER_FEED.matches(formattedString)) { - Map matchMap = FOLDER_FEED.match(formattedString); - return ofFolderFeedName(matchMap.get("folder"), matchMap.get("feed")); - } else if (ORGANIZATION_FEED.matches(formattedString)) { - Map matchMap = ORGANIZATION_FEED.match(formattedString); - return ofOrganizationFeedName(matchMap.get("organization"), matchMap.get("feed")); - } - throw new ValidationException("FeedName.parse: formattedString not in valid format"); - } - - public static List parseList(List formattedStrings) { - List list = new ArrayList<>(formattedStrings.size()); - for (String formattedString : formattedStrings) { - list.add(parse(formattedString)); - } - return list; - } - - public static List toStringList(List values) { - List list = new ArrayList<>(values.size()); - for (FeedName value : values) { - if (value == null) { - list.add(""); - } else { - list.add(value.toString()); - } - } - return list; - } - - public static boolean isParsableFrom(String formattedString) { - return PROJECT_FEED.matches(formattedString) - || FOLDER_FEED.matches(formattedString) - || ORGANIZATION_FEED.matches(formattedString); - } - - @Override - public Map getFieldValuesMap() { - if (fieldValuesMap == null) { - synchronized (this) { - if (fieldValuesMap == null) { - ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (project != null) { - fieldMapBuilder.put("project", project); - } - if (feed != null) { - fieldMapBuilder.put("feed", feed); - } - if (folder != null) { - fieldMapBuilder.put("folder", folder); - } - if (organization != null) { - fieldMapBuilder.put("organization", organization); - } - fieldValuesMap = fieldMapBuilder.build(); - } - } - } - return fieldValuesMap; - } - - public String getFieldValue(String fieldName) { - return getFieldValuesMap().get(fieldName); - } - - @Override - public String toString() { - return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - FeedName that = ((FeedName) o); - return Objects.equals(this.project, that.project) - && Objects.equals(this.feed, that.feed) - && Objects.equals(this.folder, that.folder) - && Objects.equals(this.organization, that.organization); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(fixedValue); - h *= 1000003; - h ^= Objects.hashCode(project); - h *= 1000003; - h ^= Objects.hashCode(feed); - h *= 1000003; - h ^= Objects.hashCode(folder); - h *= 1000003; - h ^= Objects.hashCode(organization); - return h; - } - - /** Builder for projects/{project}/feeds/{feed}. */ - public static class Builder { - private String project; - private String feed; - - protected Builder() {} - - public String getProject() { - return project; - } - - public String getFeed() { - return feed; - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setFeed(String feed) { - this.feed = feed; - return this; - } - - private Builder(FeedName feedName) { - Preconditions.checkArgument( - Objects.equals(feedName.pathTemplate, PROJECT_FEED), - "toBuilder is only supported when FeedName has the pattern of projects/{project}/feeds/{feed}"); - project = feedName.project; - feed = feedName.feed; - } - - public FeedName build() { - return new FeedName(this); - } - } - - /** Builder for folders/{folder}/feeds/{feed}. */ - @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static class FolderFeedBuilder { - private String folder; - private String feed; - - protected FolderFeedBuilder() {} - - public String getFolder() { - return folder; - } - - public String getFeed() { - return feed; - } - - public FolderFeedBuilder setFolder(String folder) { - this.folder = folder; - return this; - } - - public FolderFeedBuilder setFeed(String feed) { - this.feed = feed; - return this; - } - - public FeedName build() { - return new FeedName(this); - } - } - - /** Builder for organizations/{organization}/feeds/{feed}. */ - @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") - public static class OrganizationFeedBuilder { - private String organization; - private String feed; - - protected OrganizationFeedBuilder() {} - - public String getOrganization() { - return organization; - } - - public String getFeed() { - return feed; - } - - public OrganizationFeedBuilder setOrganization(String organization) { - this.organization = organization; - return this; - } - - public OrganizationFeedBuilder setFeed(String feed) { - this.feed = feed; - return this; - } - - public FeedName build() { - return new FeedName(this); - } - } -} diff --git a/test/integration/goldens/asset/GrpcAssetServiceCallableFactory.java b/test/integration/goldens/asset/GrpcAssetServiceCallableFactory.java index e67f9e56fa..374934f547 100644 --- a/test/integration/goldens/asset/GrpcAssetServiceCallableFactory.java +++ b/test/integration/goldens/asset/GrpcAssetServiceCallableFactory.java @@ -14,8 +14,9 @@ * limitations under the License. */ -package com.google.cloud.asset.v1.stub; +package com.google.cloud.asset.v1beta1.stub; +import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -41,7 +42,8 @@ * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@BetaApi +@Generated("by gapic-generator-java") public class GrpcAssetServiceCallableFactory implements GrpcStubCallableFactory { @Override diff --git a/test/integration/goldens/asset/GrpcAssetServiceStub.java b/test/integration/goldens/asset/GrpcAssetServiceStub.java index b613cceb4e..962ca1342c 100644 --- a/test/integration/goldens/asset/GrpcAssetServiceStub.java +++ b/test/integration/goldens/asset/GrpcAssetServiceStub.java @@ -14,11 +14,9 @@ * limitations under the License. */ -package com.google.cloud.asset.v1.stub; - -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; -import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; +package com.google.cloud.asset.v1beta1.stub; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -27,25 +25,13 @@ import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest; -import com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse; -import com.google.cloud.asset.v1.CreateFeedRequest; -import com.google.cloud.asset.v1.DeleteFeedRequest; -import com.google.cloud.asset.v1.ExportAssetsRequest; -import com.google.cloud.asset.v1.ExportAssetsResponse; -import com.google.cloud.asset.v1.Feed; -import com.google.cloud.asset.v1.GetFeedRequest; -import com.google.cloud.asset.v1.ListFeedsRequest; -import com.google.cloud.asset.v1.ListFeedsResponse; -import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest; -import com.google.cloud.asset.v1.SearchAllIamPoliciesResponse; -import com.google.cloud.asset.v1.SearchAllResourcesRequest; -import com.google.cloud.asset.v1.SearchAllResourcesResponse; -import com.google.cloud.asset.v1.UpdateFeedRequest; +import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryRequest; +import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryResponse; +import com.google.cloud.asset.v1beta1.ExportAssetsRequest; +import com.google.cloud.asset.v1beta1.ExportAssetsResponse; import com.google.common.collect.ImmutableMap; import com.google.longrunning.Operation; import com.google.longrunning.stub.GrpcOperationsStub; -import com.google.protobuf.Empty; import io.grpc.MethodDescriptor; import io.grpc.protobuf.ProtoUtils; import java.io.IOException; @@ -59,13 +45,14 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ +@BetaApi @Generated("by gapic-generator-java") public class GrpcAssetServiceStub extends AssetServiceStub { private static final MethodDescriptor exportAssetsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/ExportAssets") + .setFullMethodName("google.cloud.asset.v1beta1.AssetService/ExportAssets") .setRequestMarshaller(ProtoUtils.marshaller(ExportAssetsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); @@ -74,94 +61,18 @@ public class GrpcAssetServiceStub extends AssetServiceStub { batchGetAssetsHistoryMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/BatchGetAssetsHistory") + .setFullMethodName("google.cloud.asset.v1beta1.AssetService/BatchGetAssetsHistory") .setRequestMarshaller( ProtoUtils.marshaller(BatchGetAssetsHistoryRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(BatchGetAssetsHistoryResponse.getDefaultInstance())) .build(); - private static final MethodDescriptor createFeedMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/CreateFeed") - .setRequestMarshaller(ProtoUtils.marshaller(CreateFeedRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Feed.getDefaultInstance())) - .build(); - - private static final MethodDescriptor getFeedMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/GetFeed") - .setRequestMarshaller(ProtoUtils.marshaller(GetFeedRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Feed.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - listFeedsMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/ListFeeds") - .setRequestMarshaller(ProtoUtils.marshaller(ListFeedsRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(ListFeedsResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor updateFeedMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/UpdateFeed") - .setRequestMarshaller(ProtoUtils.marshaller(UpdateFeedRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Feed.getDefaultInstance())) - .build(); - - private static final MethodDescriptor deleteFeedMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/DeleteFeed") - .setRequestMarshaller(ProtoUtils.marshaller(DeleteFeedRequest.getDefaultInstance())) - .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - searchAllResourcesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/SearchAllResources") - .setRequestMarshaller( - ProtoUtils.marshaller(SearchAllResourcesRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(SearchAllResourcesResponse.getDefaultInstance())) - .build(); - - private static final MethodDescriptor - searchAllIamPoliciesMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1.AssetService/SearchAllIamPolicies") - .setRequestMarshaller( - ProtoUtils.marshaller(SearchAllIamPoliciesRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(SearchAllIamPoliciesResponse.getDefaultInstance())) - .build(); - private final UnaryCallable exportAssetsCallable; private final OperationCallable exportAssetsOperationCallable; private final UnaryCallable batchGetAssetsHistoryCallable; - private final UnaryCallable createFeedCallable; - private final UnaryCallable getFeedCallable; - private final UnaryCallable listFeedsCallable; - private final UnaryCallable updateFeedCallable; - private final UnaryCallable deleteFeedCallable; - private final UnaryCallable - searchAllResourcesCallable; - private final UnaryCallable - searchAllResourcesPagedCallable; - private final UnaryCallable - searchAllIamPoliciesCallable; - private final UnaryCallable - searchAllIamPoliciesPagedCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; @@ -233,99 +144,6 @@ public Map extract(BatchGetAssetsHistoryRequest request) { } }) .build(); - GrpcCallSettings createFeedTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(createFeedMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(CreateFeedRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings getFeedTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(getFeedMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(GetFeedRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings listFeedsTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(listFeedsMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(ListFeedsRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("parent", String.valueOf(request.getParent())); - return params.build(); - } - }) - .build(); - GrpcCallSettings updateFeedTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(updateFeedMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(UpdateFeedRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("feed.name", String.valueOf(request.getFeed().getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings deleteFeedTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(deleteFeedMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(DeleteFeedRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("name", String.valueOf(request.getName())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - searchAllResourcesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(searchAllResourcesMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SearchAllResourcesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("scope", String.valueOf(request.getScope())); - return params.build(); - } - }) - .build(); - GrpcCallSettings - searchAllIamPoliciesTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(searchAllIamPoliciesMethodDescriptor) - .setParamsExtractor( - new RequestParamsExtractor() { - @Override - public Map extract(SearchAllIamPoliciesRequest request) { - ImmutableMap.Builder params = ImmutableMap.builder(); - params.put("scope", String.valueOf(request.getScope())); - return params.build(); - } - }) - .build(); this.exportAssetsCallable = callableFactory.createUnaryCallable( @@ -341,41 +159,6 @@ public Map extract(SearchAllIamPoliciesRequest request) { batchGetAssetsHistoryTransportSettings, settings.batchGetAssetsHistorySettings(), clientContext); - this.createFeedCallable = - callableFactory.createUnaryCallable( - createFeedTransportSettings, settings.createFeedSettings(), clientContext); - this.getFeedCallable = - callableFactory.createUnaryCallable( - getFeedTransportSettings, settings.getFeedSettings(), clientContext); - this.listFeedsCallable = - callableFactory.createUnaryCallable( - listFeedsTransportSettings, settings.listFeedsSettings(), clientContext); - this.updateFeedCallable = - callableFactory.createUnaryCallable( - updateFeedTransportSettings, settings.updateFeedSettings(), clientContext); - this.deleteFeedCallable = - callableFactory.createUnaryCallable( - deleteFeedTransportSettings, settings.deleteFeedSettings(), clientContext); - this.searchAllResourcesCallable = - callableFactory.createUnaryCallable( - searchAllResourcesTransportSettings, - settings.searchAllResourcesSettings(), - clientContext); - this.searchAllResourcesPagedCallable = - callableFactory.createPagedCallable( - searchAllResourcesTransportSettings, - settings.searchAllResourcesSettings(), - clientContext); - this.searchAllIamPoliciesCallable = - callableFactory.createUnaryCallable( - searchAllIamPoliciesTransportSettings, - settings.searchAllIamPoliciesSettings(), - clientContext); - this.searchAllIamPoliciesPagedCallable = - callableFactory.createPagedCallable( - searchAllIamPoliciesTransportSettings, - settings.searchAllIamPoliciesSettings(), - clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -399,46 +182,6 @@ public UnaryCallable exportAssetsCallable() { return batchGetAssetsHistoryCallable; } - public UnaryCallable createFeedCallable() { - return createFeedCallable; - } - - public UnaryCallable getFeedCallable() { - return getFeedCallable; - } - - public UnaryCallable listFeedsCallable() { - return listFeedsCallable; - } - - public UnaryCallable updateFeedCallable() { - return updateFeedCallable; - } - - public UnaryCallable deleteFeedCallable() { - return deleteFeedCallable; - } - - public UnaryCallable - searchAllResourcesCallable() { - return searchAllResourcesCallable; - } - - public UnaryCallable - searchAllResourcesPagedCallable() { - return searchAllResourcesPagedCallable; - } - - public UnaryCallable - searchAllIamPoliciesCallable() { - return searchAllIamPoliciesCallable; - } - - public UnaryCallable - searchAllIamPoliciesPagedCallable() { - return searchAllIamPoliciesPagedCallable; - } - @Override public final void close() { shutdown(); diff --git a/test/integration/goldens/asset/MockAssetService.java b/test/integration/goldens/asset/MockAssetService.java index 140e701a9e..b7022c2b57 100644 --- a/test/integration/goldens/asset/MockAssetService.java +++ b/test/integration/goldens/asset/MockAssetService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.cloud.asset.v1; +package com.google.cloud.asset.v1beta1; import com.google.api.core.BetaApi; import com.google.api.gax.grpc.testing.MockGrpcService; diff --git a/test/integration/goldens/asset/MockAssetServiceImpl.java b/test/integration/goldens/asset/MockAssetServiceImpl.java index 1ef582b272..279e8a2c43 100644 --- a/test/integration/goldens/asset/MockAssetServiceImpl.java +++ b/test/integration/goldens/asset/MockAssetServiceImpl.java @@ -14,13 +14,12 @@ * limitations under the License. */ -package com.google.cloud.asset.v1; +package com.google.cloud.asset.v1beta1; import com.google.api.core.BetaApi; -import com.google.cloud.asset.v1.AssetServiceGrpc.AssetServiceImplBase; +import com.google.cloud.asset.v1beta1.AssetServiceGrpc.AssetServiceImplBase; import com.google.longrunning.Operation; import com.google.protobuf.AbstractMessage; -import com.google.protobuf.Empty; import io.grpc.stub.StreamObserver; import java.util.ArrayList; import java.util.LinkedList; @@ -90,107 +89,4 @@ public void batchGetAssetsHistory( responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } } - - @Override - public void createFeed(CreateFeedRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Feed) { - requests.add(request); - responseObserver.onNext(((Feed) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void getFeed(GetFeedRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Feed) { - requests.add(request); - responseObserver.onNext(((Feed) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void listFeeds( - ListFeedsRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof ListFeedsResponse) { - requests.add(request); - responseObserver.onNext(((ListFeedsResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void updateFeed(UpdateFeedRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Feed) { - requests.add(request); - responseObserver.onNext(((Feed) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void deleteFeed(DeleteFeedRequest request, StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof Empty) { - requests.add(request); - responseObserver.onNext(((Empty) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void searchAllResources( - SearchAllResourcesRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof SearchAllResourcesResponse) { - requests.add(request); - responseObserver.onNext(((SearchAllResourcesResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } - - @Override - public void searchAllIamPolicies( - SearchAllIamPoliciesRequest request, - StreamObserver responseObserver) { - Object response = responses.remove(); - if (response instanceof SearchAllIamPoliciesResponse) { - requests.add(request); - responseObserver.onNext(((SearchAllIamPoliciesResponse) response)); - responseObserver.onCompleted(); - } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); - } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); - } - } } diff --git a/test/integration/goldens/asset/PlaceholderFile.java b/test/integration/goldens/asset/PlaceholderFile.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/goldens/asset/package-info.java b/test/integration/goldens/asset/package-info.java index e57f641808..f889373e0f 100644 --- a/test/integration/goldens/asset/package-info.java +++ b/test/integration/goldens/asset/package-info.java @@ -24,6 +24,6 @@ *

Sample for AssetServiceClient: */ @Generated("by gapic-generator-java") -package com.google.cloud.asset.v1; +package com.google.cloud.asset.v1beta1; import javax.annotation.Generated; diff --git a/test/integration/goldens/credentials/GrpcIamCredentialsCallableFactory.java b/test/integration/goldens/credentials/GrpcIamCredentialsCallableFactory.java index 6dc31820a3..32b29d4f33 100644 --- a/test/integration/goldens/credentials/GrpcIamCredentialsCallableFactory.java +++ b/test/integration/goldens/credentials/GrpcIamCredentialsCallableFactory.java @@ -41,7 +41,7 @@ * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class GrpcIamCredentialsCallableFactory implements GrpcStubCallableFactory { @Override diff --git a/test/integration/goldens/credentials/IamCredentialsClient.java b/test/integration/goldens/credentials/IamCredentialsClient.java index e3699cdcc0..ecaed011f3 100644 --- a/test/integration/goldens/credentials/IamCredentialsClient.java +++ b/test/integration/goldens/credentials/IamCredentialsClient.java @@ -88,8 +88,7 @@ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class IamCredentialsClient implements BackgroundResource { private final IamCredentialsSettings settings; private final IamCredentialsStub stub; diff --git a/test/integration/goldens/credentials/IamCredentialsStub.java b/test/integration/goldens/credentials/IamCredentialsStub.java index 8b195e93b0..9a269e4bfc 100644 --- a/test/integration/goldens/credentials/IamCredentialsStub.java +++ b/test/integration/goldens/credentials/IamCredentialsStub.java @@ -34,7 +34,7 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public abstract class IamCredentialsStub implements BackgroundResource { public UnaryCallable diff --git a/test/integration/goldens/credentials/IamCredentialsStubSettings.java b/test/integration/goldens/credentials/IamCredentialsStubSettings.java index d86322d07b..05f986fbf4 100644 --- a/test/integration/goldens/credentials/IamCredentialsStubSettings.java +++ b/test/integration/goldens/credentials/IamCredentialsStubSettings.java @@ -81,7 +81,6 @@ * IamCredentialsStubSettings iamCredentialsSettings = iamCredentialsSettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class IamCredentialsStubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/test/integration/goldens/library/GrpcLibraryServiceCallableFactory.java b/test/integration/goldens/library/GrpcLibraryServiceCallableFactory.java index 50414f7b6b..1732f3129d 100644 --- a/test/integration/goldens/library/GrpcLibraryServiceCallableFactory.java +++ b/test/integration/goldens/library/GrpcLibraryServiceCallableFactory.java @@ -41,7 +41,7 @@ * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class GrpcLibraryServiceCallableFactory implements GrpcStubCallableFactory { @Override diff --git a/test/integration/goldens/library/LibraryServiceClient.java b/test/integration/goldens/library/LibraryServiceClient.java index a8303d5fe3..b574501da4 100644 --- a/test/integration/goldens/library/LibraryServiceClient.java +++ b/test/integration/goldens/library/LibraryServiceClient.java @@ -112,8 +112,7 @@ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class LibraryServiceClient implements BackgroundResource { private final LibraryServiceSettings settings; private final LibraryServiceStub stub; diff --git a/test/integration/goldens/library/LibraryServiceStub.java b/test/integration/goldens/library/LibraryServiceStub.java index c256e68362..48eaf7b070 100644 --- a/test/integration/goldens/library/LibraryServiceStub.java +++ b/test/integration/goldens/library/LibraryServiceStub.java @@ -45,7 +45,7 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public abstract class LibraryServiceStub implements BackgroundResource { public UnaryCallable createShelfCallable() { diff --git a/test/integration/goldens/library/LibraryServiceStubSettings.java b/test/integration/goldens/library/LibraryServiceStubSettings.java index bc16111efe..d36fe4d22f 100644 --- a/test/integration/goldens/library/LibraryServiceStubSettings.java +++ b/test/integration/goldens/library/LibraryServiceStubSettings.java @@ -98,7 +98,6 @@ * LibraryServiceStubSettings libraryServiceSettings = libraryServiceSettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class LibraryServiceStubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/test/integration/goldens/logging/ConfigClient.java b/test/integration/goldens/logging/ConfigClient.java index c328da1caf..678d5300e6 100644 --- a/test/integration/goldens/logging/ConfigClient.java +++ b/test/integration/goldens/logging/ConfigClient.java @@ -120,8 +120,7 @@ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class ConfigClient implements BackgroundResource { private final ConfigSettings settings; private final ConfigServiceV2Stub stub; diff --git a/test/integration/goldens/logging/ConfigServiceV2Stub.java b/test/integration/goldens/logging/ConfigServiceV2Stub.java index a3d770adb0..e0e867e11d 100644 --- a/test/integration/goldens/logging/ConfigServiceV2Stub.java +++ b/test/integration/goldens/logging/ConfigServiceV2Stub.java @@ -53,7 +53,7 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public abstract class ConfigServiceV2Stub implements BackgroundResource { public UnaryCallable listBucketsPagedCallable() { diff --git a/test/integration/goldens/logging/ConfigServiceV2StubSettings.java b/test/integration/goldens/logging/ConfigServiceV2StubSettings.java index 82472fa977..9665b4956b 100644 --- a/test/integration/goldens/logging/ConfigServiceV2StubSettings.java +++ b/test/integration/goldens/logging/ConfigServiceV2StubSettings.java @@ -106,7 +106,6 @@ * ConfigServiceV2StubSettings configServiceV2Settings = configServiceV2SettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class ConfigServiceV2StubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/test/integration/goldens/logging/GrpcConfigServiceV2CallableFactory.java b/test/integration/goldens/logging/GrpcConfigServiceV2CallableFactory.java index a6b77d5f5d..b71fdfc862 100644 --- a/test/integration/goldens/logging/GrpcConfigServiceV2CallableFactory.java +++ b/test/integration/goldens/logging/GrpcConfigServiceV2CallableFactory.java @@ -41,7 +41,7 @@ * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class GrpcConfigServiceV2CallableFactory implements GrpcStubCallableFactory { @Override diff --git a/test/integration/goldens/logging/GrpcLoggingServiceV2CallableFactory.java b/test/integration/goldens/logging/GrpcLoggingServiceV2CallableFactory.java index b9399e7ee1..1779d7c70b 100644 --- a/test/integration/goldens/logging/GrpcLoggingServiceV2CallableFactory.java +++ b/test/integration/goldens/logging/GrpcLoggingServiceV2CallableFactory.java @@ -41,7 +41,7 @@ * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class GrpcLoggingServiceV2CallableFactory implements GrpcStubCallableFactory { @Override diff --git a/test/integration/goldens/logging/GrpcMetricsServiceV2CallableFactory.java b/test/integration/goldens/logging/GrpcMetricsServiceV2CallableFactory.java index d3f407cf31..ea54e8e76c 100644 --- a/test/integration/goldens/logging/GrpcMetricsServiceV2CallableFactory.java +++ b/test/integration/goldens/logging/GrpcMetricsServiceV2CallableFactory.java @@ -41,7 +41,7 @@ * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class GrpcMetricsServiceV2CallableFactory implements GrpcStubCallableFactory { @Override diff --git a/test/integration/goldens/logging/LoggingClient.java b/test/integration/goldens/logging/LoggingClient.java index 8b7fcd0f2b..3f47e0ebaa 100644 --- a/test/integration/goldens/logging/LoggingClient.java +++ b/test/integration/goldens/logging/LoggingClient.java @@ -105,8 +105,7 @@ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class LoggingClient implements BackgroundResource { private final LoggingSettings settings; private final LoggingServiceV2Stub stub; diff --git a/test/integration/goldens/logging/LoggingServiceV2Stub.java b/test/integration/goldens/logging/LoggingServiceV2Stub.java index 40e608ddae..7a18b2cc33 100644 --- a/test/integration/goldens/logging/LoggingServiceV2Stub.java +++ b/test/integration/goldens/logging/LoggingServiceV2Stub.java @@ -40,7 +40,7 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public abstract class LoggingServiceV2Stub implements BackgroundResource { public UnaryCallable deleteLogCallable() { diff --git a/test/integration/goldens/logging/LoggingServiceV2StubSettings.java b/test/integration/goldens/logging/LoggingServiceV2StubSettings.java index 47b910ab99..e62a198503 100644 --- a/test/integration/goldens/logging/LoggingServiceV2StubSettings.java +++ b/test/integration/goldens/logging/LoggingServiceV2StubSettings.java @@ -104,7 +104,6 @@ * LoggingServiceV2StubSettings loggingServiceV2Settings = loggingServiceV2SettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class LoggingServiceV2StubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/test/integration/goldens/logging/MetricsClient.java b/test/integration/goldens/logging/MetricsClient.java index 3d105de40d..14ccc5d1a4 100644 --- a/test/integration/goldens/logging/MetricsClient.java +++ b/test/integration/goldens/logging/MetricsClient.java @@ -96,8 +96,7 @@ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class MetricsClient implements BackgroundResource { private final MetricsSettings settings; private final MetricsServiceV2Stub stub; diff --git a/test/integration/goldens/logging/MetricsServiceV2Stub.java b/test/integration/goldens/logging/MetricsServiceV2Stub.java index 41151d0238..5cf37e71a8 100644 --- a/test/integration/goldens/logging/MetricsServiceV2Stub.java +++ b/test/integration/goldens/logging/MetricsServiceV2Stub.java @@ -36,7 +36,7 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public abstract class MetricsServiceV2Stub implements BackgroundResource { public UnaryCallable diff --git a/test/integration/goldens/logging/MetricsServiceV2StubSettings.java b/test/integration/goldens/logging/MetricsServiceV2StubSettings.java index 94082fb1c4..c3b691f2c6 100644 --- a/test/integration/goldens/logging/MetricsServiceV2StubSettings.java +++ b/test/integration/goldens/logging/MetricsServiceV2StubSettings.java @@ -89,7 +89,6 @@ * MetricsServiceV2StubSettings metricsServiceV2Settings = metricsServiceV2SettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class MetricsServiceV2StubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index ae14c03a63..a9bd0a72a9 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -112,8 +112,7 @@ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class CloudRedisClient implements BackgroundResource { private final CloudRedisSettings settings; private final CloudRedisStub stub; diff --git a/test/integration/goldens/redis/CloudRedisStub.java b/test/integration/goldens/redis/CloudRedisStub.java index cb83fee1eb..86a7d63e4e 100644 --- a/test/integration/goldens/redis/CloudRedisStub.java +++ b/test/integration/goldens/redis/CloudRedisStub.java @@ -44,7 +44,7 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public abstract class CloudRedisStub implements BackgroundResource { public OperationsStub getOperationsStub() { diff --git a/test/integration/goldens/redis/CloudRedisStubSettings.java b/test/integration/goldens/redis/CloudRedisStubSettings.java index 85739cc9a1..7588be3456 100644 --- a/test/integration/goldens/redis/CloudRedisStubSettings.java +++ b/test/integration/goldens/redis/CloudRedisStubSettings.java @@ -98,7 +98,6 @@ * CloudRedisStubSettings cloudRedisSettings = cloudRedisSettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class CloudRedisStubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/test/integration/goldens/redis/GrpcCloudRedisCallableFactory.java b/test/integration/goldens/redis/GrpcCloudRedisCallableFactory.java index 7631c208ea..f827378089 100644 --- a/test/integration/goldens/redis/GrpcCloudRedisCallableFactory.java +++ b/test/integration/goldens/redis/GrpcCloudRedisCallableFactory.java @@ -41,7 +41,7 @@ * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class GrpcCloudRedisCallableFactory implements GrpcStubCallableFactory { @Override From f55ae4dcaebdd70c41485d18504f0fb4a437fb28 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Thu, 7 Jan 2021 17:22:47 -0800 Subject: [PATCH 3/3] fix: update integration tests --- test/integration/BUILD.bazel | 38 +- .../goldens/asset/AssetServiceClient.java | 653 +++++++++++++++++- .../goldens/asset/AssetServiceClientTest.java | 388 ++++++++++- .../goldens/asset/AssetServiceSettings.java | 92 ++- .../goldens/asset/AssetServiceStub.java | 67 +- .../asset/AssetServiceStubSettings.java | 366 +++++++++- test/integration/goldens/asset/FeedName.java | 368 ++++++++++ .../GrpcAssetServiceCallableFactory.java | 4 +- .../goldens/asset/GrpcAssetServiceStub.java | 275 +++++++- .../goldens/asset/MockAssetService.java | 2 +- .../goldens/asset/MockAssetServiceImpl.java | 108 ++- .../goldens/asset/PlaceholderFile.java | 0 .../goldens/asset/package-info.java | 2 +- .../goldens/redis/CloudRedisClient.java | 70 +- .../goldens/redis/CloudRedisClientTest.java | 4 +- .../goldens/redis/CloudRedisSettings.java | 36 +- .../goldens/redis/CloudRedisStub.java | 49 +- .../goldens/redis/CloudRedisStubSettings.java | 109 ++- .../redis/GrpcCloudRedisCallableFactory.java | 4 +- .../goldens/redis/GrpcCloudRedisStub.java | 81 ++- .../goldens/redis/InstanceName.java | 2 +- .../goldens/redis/LocationName.java | 2 +- .../goldens/redis/MockCloudRedis.java | 2 +- .../goldens/redis/MockCloudRedisImpl.java | 4 +- .../goldens/redis/package-info.java | 6 +- 25 files changed, 2459 insertions(+), 273 deletions(-) create mode 100644 test/integration/goldens/asset/FeedName.java delete mode 100644 test/integration/goldens/asset/PlaceholderFile.java diff --git a/test/integration/BUILD.bazel b/test/integration/BUILD.bazel index aacf5e0805..449f19b19d 100644 --- a/test/integration/BUILD.bazel +++ b/test/integration/BUILD.bazel @@ -45,14 +45,14 @@ INTEGRATION_TEST_LIBRARIES = [ # Asset API. java_gapic_library( name = "asset_java_gapic", - srcs = ["@com_google_googleapis//google/cloud/asset/v1beta1:asset_proto_with_info"], - grpc_service_config = "@com_google_googleapis//google/cloud/asset/v1beta1:cloudasset_grpc_service_config.json", + srcs = ["@com_google_googleapis//google/cloud/asset/v1:asset_proto_with_info"], + grpc_service_config = "@com_google_googleapis//google/cloud/asset/v1:cloudasset_grpc_service_config.json", test_deps = [ - "@com_google_googleapis//google/cloud/asset/v1beta1:asset_java_grpc", + "@com_google_googleapis//google/cloud/asset/v1:asset_java_grpc", "@com_google_googleapis//google/iam/v1:iam_java_grpc", ], deps = [ - "@com_google_googleapis//google/cloud/asset/v1beta1:asset_java_proto", + "@com_google_googleapis//google/cloud/asset/v1:asset_java_proto", "@com_google_googleapis//google/iam/v1:iam_java_proto", "@com_google_googleapis//google/identity/accesscontextmanager/v1:accesscontextmanager_proto", ], @@ -61,18 +61,18 @@ java_gapic_library( java_gapic_test( name = "asset_java_gapic_test_suite", test_classes = [ - "com.google.cloud.asset.v1beta1.AssetServiceClientTest", + "com.google.cloud.asset.v1.AssetServiceClientTest", ], runtime_deps = [":asset_java_gapic_test"], ) java_gapic_assembly_gradle_pkg( - name = "google-cloud-asset-v1beta1-java", + name = "google-cloud-asset-v1-java", deps = [ ":asset_java_gapic", - "@com_google_googleapis//google/cloud/asset/v1beta1:asset_java_grpc", - "@com_google_googleapis//google/cloud/asset/v1beta1:asset_java_proto", - "@com_google_googleapis//google/cloud/asset/v1beta1:asset_proto", + "@com_google_googleapis//google/cloud/asset/v1:asset_java_grpc", + "@com_google_googleapis//google/cloud/asset/v1:asset_java_proto", + "@com_google_googleapis//google/cloud/asset/v1:asset_proto", "@com_google_googleapis//google/cloud/orgpolicy/v1:orgpolicy_java_proto", "@com_google_googleapis//google/identity/accesscontextmanager/v1:accesscontextmanager_java_proto", ], @@ -81,32 +81,32 @@ java_gapic_assembly_gradle_pkg( # Redis API. java_gapic_library( name = "redis_java_gapic", - srcs = ["@com_google_googleapis//google/cloud/redis/v1:redis_proto_with_info"], - gapic_yaml = "@com_google_googleapis//google/cloud/redis/v1:redis_gapic.yaml", - grpc_service_config = "@com_google_googleapis//google/cloud/redis/v1:redis_grpc_service_config.json", + srcs = ["@com_google_googleapis//google/cloud/redis/v1beta1:redis_proto_with_info"], + gapic_yaml = "@com_google_googleapis//google/cloud/redis/v1beta1:redis_gapic.yaml", + grpc_service_config = "@com_google_googleapis//google/cloud/redis/v1beta1:redis_grpc_service_config.json", test_deps = [ - "@com_google_googleapis//google/cloud/redis/v1:redis_java_grpc", + "@com_google_googleapis//google/cloud/redis/v1beta1:redis_java_grpc", ], deps = [ - "@com_google_googleapis//google/cloud/redis/v1:redis_java_proto", + "@com_google_googleapis//google/cloud/redis/v1beta1:redis_java_proto", ], ) java_gapic_test( name = "redis_java_gapic_test_suite", test_classes = [ - "com.google.cloud.redis.v1.CloudRedisClientTest", + "com.google.cloud.redis.v1beta1.CloudRedisClientTest", ], runtime_deps = [":redis_java_gapic_test"], ) java_gapic_assembly_gradle_pkg( - name = "google-cloud-redis-v1-java", + name = "google-cloud-redis-v1beta1-java", deps = [ ":redis_java_gapic", - "@com_google_googleapis//google/cloud/redis/v1:redis_java_grpc", - "@com_google_googleapis//google/cloud/redis/v1:redis_java_proto", - "@com_google_googleapis//google/cloud/redis/v1:redis_proto", + "@com_google_googleapis//google/cloud/redis/v1beta1:redis_java_grpc", + "@com_google_googleapis//google/cloud/redis/v1beta1:redis_java_proto", + "@com_google_googleapis//google/cloud/redis/v1beta1:redis_proto", ], ) diff --git a/test/integration/goldens/asset/AssetServiceClient.java b/test/integration/goldens/asset/AssetServiceClient.java index 17d5c02974..631aa590a6 100644 --- a/test/integration/goldens/asset/AssetServiceClient.java +++ b/test/integration/goldens/asset/AssetServiceClient.java @@ -14,18 +14,28 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1; +package com.google.cloud.asset.v1; +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.asset.v1beta1.stub.AssetServiceStub; -import com.google.cloud.asset.v1beta1.stub.AssetServiceStubSettings; +import com.google.cloud.asset.v1.stub.AssetServiceStub; +import com.google.cloud.asset.v1.stub.AssetServiceStubSettings; +import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; import com.google.longrunning.OperationsClient; +import com.google.protobuf.Empty; import java.io.IOException; +import java.util.List; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -82,7 +92,6 @@ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@BetaApi @Generated("by gapic-generator-java") public class AssetServiceClient implements BackgroundResource { private final AssetServiceSettings settings; @@ -148,10 +157,14 @@ public final OperationsClient getOperationsClient() { // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Exports assets with time and resource types to a given Cloud Storage location. The output - * format is newline-delimited JSON. This API implements the - * [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of - * the export. + * Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. + * For Cloud Storage location destinations, the output format is newline-delimited JSON. Each line + * represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for + * BigQuery table destinations, the output table stores the fields in asset proto as columns. This + * API implements the [google.longrunning.Operation][google.longrunning.Operation] API , which + * allows you to keep track of the export. We recommend intervals of at least 2 seconds with + * exponential retry to poll the export operation result. For regular-size resource parent, the + * export operation usually finishes within 5 minutes. * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -163,10 +176,14 @@ public final OperationFuture exportAs // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Exports assets with time and resource types to a given Cloud Storage location. The output - * format is newline-delimited JSON. This API implements the - * [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of - * the export. + * Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. + * For Cloud Storage location destinations, the output format is newline-delimited JSON. Each line + * represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for + * BigQuery table destinations, the output table stores the fields in asset proto as columns. This + * API implements the [google.longrunning.Operation][google.longrunning.Operation] API , which + * allows you to keep track of the export. We recommend intervals of at least 2 seconds with + * exponential retry to poll the export operation result. For regular-size resource parent, the + * export operation usually finishes within 5 minutes. * *

Sample code: */ @@ -177,10 +194,14 @@ public final OperationFuture exportAs // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Exports assets with time and resource types to a given Cloud Storage location. The output - * format is newline-delimited JSON. This API implements the - * [google.longrunning.Operation][google.longrunning.Operation] API allowing you to keep track of - * the export. + * Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. + * For Cloud Storage location destinations, the output format is newline-delimited JSON. Each line + * represents a [google.cloud.asset.v1.Asset][google.cloud.asset.v1.Asset] in the JSON format; for + * BigQuery table destinations, the output table stores the fields in asset proto as columns. This + * API implements the [google.longrunning.Operation][google.longrunning.Operation] API , which + * allows you to keep track of the export. We recommend intervals of at least 2 seconds with + * exponential retry to poll the export operation result. For regular-size resource parent, the + * export operation usually finishes within 5 minutes. * *

Sample code: */ @@ -190,11 +211,11 @@ public final UnaryCallable exportAssetsCallable( // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Batch gets the update history of assets that overlap a time window. For RESOURCE content, this - * API outputs history with asset in both non-delete or deleted status. For IAM_POLICY content, + * Batch gets the update history of assets that overlap a time window. For IAM_POLICY content, * this API outputs history when the asset and its attached IAM POLICY both exist. This can create - * gaps in the output history. If a specified asset does not exist, this API returns an - * INVALID_ARGUMENT error. + * gaps in the output history. Otherwise, this API outputs history with asset in both non-delete + * or deleted status. If a specified asset does not exist, this API returns an INVALID_ARGUMENT + * error. * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -206,11 +227,11 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( // AUTO-GENERATED DOCUMENTATION AND METHOD. /** - * Batch gets the update history of assets that overlap a time window. For RESOURCE content, this - * API outputs history with asset in both non-delete or deleted status. For IAM_POLICY content, + * Batch gets the update history of assets that overlap a time window. For IAM_POLICY content, * this API outputs history when the asset and its attached IAM POLICY both exist. This can create - * gaps in the output history. If a specified asset does not exist, this API returns an - * INVALID_ARGUMENT error. + * gaps in the output history. Otherwise, this API outputs history with asset in both non-delete + * or deleted status. If a specified asset does not exist, this API returns an INVALID_ARGUMENT + * error. * *

Sample code: */ @@ -219,6 +240,408 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory( return stub.batchGetAssetsHistoryCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a feed in a parent project/folder/organization to listen to its asset updates. + * + * @param parent Required. The name of the project/folder/organization where this feed should be + * created in. It can only be an organization number (such as "organizations/123"), a folder + * number (such as "folders/123"), a project ID (such as "projects/my-project-id")", or a + * project number (such as "projects/12345"). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Feed createFeed(String parent) { + CreateFeedRequest request = CreateFeedRequest.newBuilder().setParent(parent).build(); + return createFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a feed in a parent project/folder/organization to listen to its asset updates. + * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Feed createFeed(CreateFeedRequest request) { + return createFeedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a feed in a parent project/folder/organization to listen to its asset updates. + * + *

Sample code: + */ + public final UnaryCallable createFeedCallable() { + return stub.createFeedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets details about an asset feed. + * + * @param name Required. The name of the Feed and it must be in the format of: + * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id + * organizations/organization_number/feeds/feed_id + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Feed getFeed(FeedName name) { + GetFeedRequest request = + GetFeedRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets details about an asset feed. + * + * @param name Required. The name of the Feed and it must be in the format of: + * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id + * organizations/organization_number/feeds/feed_id + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Feed getFeed(String name) { + GetFeedRequest request = GetFeedRequest.newBuilder().setName(name).build(); + return getFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets details about an asset feed. + * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Feed getFeed(GetFeedRequest request) { + return getFeedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets details about an asset feed. + * + *

Sample code: + */ + public final UnaryCallable getFeedCallable() { + return stub.getFeedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all asset feeds in a parent project/folder/organization. + * + * @param parent Required. The parent project/folder/organization whose feeds are to be listed. It + * can only be using project/folder/organization number (such as "folders/12345")", or a + * project ID (such as "projects/my-project-id"). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListFeedsResponse listFeeds(String parent) { + ListFeedsRequest request = ListFeedsRequest.newBuilder().setParent(parent).build(); + return listFeeds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all asset feeds in a parent project/folder/organization. + * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListFeedsResponse listFeeds(ListFeedsRequest request) { + return listFeedsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all asset feeds in a parent project/folder/organization. + * + *

Sample code: + */ + public final UnaryCallable listFeedsCallable() { + return stub.listFeedsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates an asset feed configuration. + * + * @param feed Required. The new values of feed details. It must match an existing feed and the + * field `name` must be in the format of: projects/project_number/feeds/feed_id or + * folders/folder_number/feeds/feed_id or organizations/organization_number/feeds/feed_id. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Feed updateFeed(Feed feed) { + UpdateFeedRequest request = UpdateFeedRequest.newBuilder().setFeed(feed).build(); + return updateFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates an asset feed configuration. + * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Feed updateFeed(UpdateFeedRequest request) { + return updateFeedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates an asset feed configuration. + * + *

Sample code: + */ + public final UnaryCallable updateFeedCallable() { + return stub.updateFeedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an asset feed. + * + * @param name Required. The name of the feed and it must be in the format of: + * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id + * organizations/organization_number/feeds/feed_id + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteFeed(FeedName name) { + DeleteFeedRequest request = + DeleteFeedRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an asset feed. + * + * @param name Required. The name of the feed and it must be in the format of: + * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id + * organizations/organization_number/feeds/feed_id + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteFeed(String name) { + DeleteFeedRequest request = DeleteFeedRequest.newBuilder().setName(name).build(); + deleteFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an asset feed. + * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteFeed(DeleteFeedRequest request) { + deleteFeedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an asset feed. + * + *

Sample code: + */ + public final UnaryCallable deleteFeedCallable() { + return stub.deleteFeedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Searches all Cloud resources within the specified scope, such as a project, folder, or + * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission + * on the desired scope, otherwise the request will be rejected. + * + * @param scope Required. A scope can be a project, a folder, or an organization. The search is + * limited to the resources within the `scope`. The caller must be granted the + * [`cloudasset.assets.searchAllResources`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) + * permission on the desired scope. + *

The allowed values are: + *

    + *
  • projects/{PROJECT_ID} (e.g., "projects/foo-bar") + *
  • projects/{PROJECT_NUMBER} (e.g., "projects/12345678") + *
  • folders/{FOLDER_NUMBER} (e.g., "folders/1234567") + *
  • organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456") + *
+ * + * @param query Optional. The query statement. See [how to construct a + * query](http://cloud.google.com/asset-inventory/docs/searching-resources#how_to_construct_a_query) + * for more information. If not specified or empty, it will search all the resources within + * the specified `scope`. Note that the query string is compared against each Cloud IAM policy + * binding, including its members, roles, and Cloud IAM conditions. The returned Cloud IAM + * policies will only contain the bindings that match your query. To learn more about the IAM + * policy structure, see [IAM policy + * doc](https://cloud.google.com/iam/docs/policies#structure). + *

Examples: + *

    + *
  • `name:Important` to find Cloud resources whose name contains "Important" as a word. + *
  • `displayName:Impor*` to find Cloud resources whose display name contains "Impor" + * as a prefix. + *
  • `description:*por*` to find Cloud resources whose description contains "por" + * as a substring. + *
  • `location:us-west*` to find Cloud resources whose location is prefixed with + * "us-west". + *
  • `labels:prod` to find Cloud resources whose labels contain "prod" as a key or value. + *
  • `labels.env:prod` to find Cloud resources that have a label "env" and its value is + * "prod". + *
  • `labels.env:*` to find Cloud resources that have a label "env". + *
  • `Important` to find Cloud resources that contain "Important" as a word in any of the + * searchable fields. + *
  • `Impor*` to find Cloud resources that contain "Impor" as a prefix in any of the + * searchable fields. + *
  • `*por*` to find Cloud resources that contain "por" as a substring in any of + * the searchable fields. + *
  • `Important location:(us-west1 OR global)` to find Cloud resources that contain + * "Important" as a word in any of the searchable fields and are also located in the + * "us-west1" region or the "global" location. + *
+ * + * @param assetTypes Optional. A list of asset types that this request searches for. If empty, it + * will search all the [searchable asset + * types](https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types). + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SearchAllResourcesPagedResponse searchAllResources( + String scope, String query, List assetTypes) { + SearchAllResourcesRequest request = + SearchAllResourcesRequest.newBuilder() + .setScope(scope) + .setQuery(query) + .addAllAssetTypes(assetTypes) + .build(); + return searchAllResources(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Searches all Cloud resources within the specified scope, such as a project, folder, or + * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission + * on the desired scope, otherwise the request will be rejected. + * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SearchAllResourcesPagedResponse searchAllResources( + SearchAllResourcesRequest request) { + return searchAllResourcesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Searches all Cloud resources within the specified scope, such as a project, folder, or + * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission + * on the desired scope, otherwise the request will be rejected. + * + *

Sample code: + */ + public final UnaryCallable + searchAllResourcesPagedCallable() { + return stub.searchAllResourcesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Searches all Cloud resources within the specified scope, such as a project, folder, or + * organization. The caller must be granted the `cloudasset.assets.searchAllResources` permission + * on the desired scope, otherwise the request will be rejected. + * + *

Sample code: + */ + public final UnaryCallable + searchAllResourcesCallable() { + return stub.searchAllResourcesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Searches all IAM policies within the specified scope, such as a project, folder, or + * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` + * permission on the desired scope, otherwise the request will be rejected. + * + * @param scope Required. A scope can be a project, a folder, or an organization. The search is + * limited to the IAM policies within the `scope`. The caller must be granted the + * [`cloudasset.assets.searchAllIamPolicies`](http://cloud.google.com/asset-inventory/docs/access-control#required_permissions) + * permission on the desired scope. + *

The allowed values are: + *

    + *
  • projects/{PROJECT_ID} (e.g., "projects/foo-bar") + *
  • projects/{PROJECT_NUMBER} (e.g., "projects/12345678") + *
  • folders/{FOLDER_NUMBER} (e.g., "folders/1234567") + *
  • organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456") + *
+ * + * @param query Optional. The query statement. See [how to construct a + * query](https://cloud.google.com/asset-inventory/docs/searching-iam-policies#how_to_construct_a_query) + * for more information. If not specified or empty, it will search all the IAM policies within + * the specified `scope`. + *

Examples: + *

    + *
  • `policy:amy{@literal @}gmail.com` to find IAM policy bindings that specify user + * "amy{@literal @}gmail.com". + *
  • `policy:roles/compute.admin` to find IAM policy bindings that specify the Compute + * Admin role. + *
  • `policy.role.permissions:storage.buckets.update` to find IAM policy bindings that + * specify a role containing "storage.buckets.update" permission. Note that if callers + * don't have `iam.roles.get` access to a role's included permissions, policy bindings + * that specify this role will be dropped from the search results. + *
  • `resource:organizations/123456` to find IAM policy bindings that are set on + * "organizations/123456". + *
  • `Important` to find IAM policy bindings that contain "Important" as a word in any of + * the searchable fields (except for the included permissions). + *
  • `*por*` to find IAM policy bindings that contain "por" as a substring in any + * of the searchable fields (except for the included permissions). + *
  • `resource:(instance1 OR instance2) policy:amy` to find IAM policy bindings that are + * set on resources "instance1" or "instance2" and also specify user "amy". + *
+ * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(String scope, String query) { + SearchAllIamPoliciesRequest request = + SearchAllIamPoliciesRequest.newBuilder().setScope(scope).setQuery(query).build(); + return searchAllIamPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Searches all IAM policies within the specified scope, such as a project, folder, or + * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` + * permission on the desired scope, otherwise the request will be rejected. + * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies( + SearchAllIamPoliciesRequest request) { + return searchAllIamPoliciesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Searches all IAM policies within the specified scope, such as a project, folder, or + * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` + * permission on the desired scope, otherwise the request will be rejected. + * + *

Sample code: + */ + public final UnaryCallable + searchAllIamPoliciesPagedCallable() { + return stub.searchAllIamPoliciesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Searches all IAM policies within the specified scope, such as a project, folder, or + * organization. The caller must be granted the `cloudasset.assets.searchAllIamPolicies` + * permission on the desired scope, otherwise the request will be rejected. + * + *

Sample code: + */ + public final UnaryCallable + searchAllIamPoliciesCallable() { + return stub.searchAllIamPoliciesCallable(); + } + @Override public final void close() { stub.close(); @@ -248,4 +671,186 @@ public void shutdownNow() { public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { return stub.awaitTermination(duration, unit); } + + public static class SearchAllResourcesPagedResponse + extends AbstractPagedListResponse< + SearchAllResourcesRequest, + SearchAllResourcesResponse, + ResourceSearchResult, + SearchAllResourcesPage, + SearchAllResourcesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext + context, + ApiFuture futureResponse) { + ApiFuture futurePage = + SearchAllResourcesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public SearchAllResourcesPagedResponse apply(SearchAllResourcesPage input) { + return new SearchAllResourcesPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private SearchAllResourcesPagedResponse(SearchAllResourcesPage page) { + super(page, SearchAllResourcesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class SearchAllResourcesPage + extends AbstractPage< + SearchAllResourcesRequest, + SearchAllResourcesResponse, + ResourceSearchResult, + SearchAllResourcesPage> { + + private SearchAllResourcesPage( + PageContext + context, + SearchAllResourcesResponse response) { + super(context, response); + } + + private static SearchAllResourcesPage createEmptyPage() { + return new SearchAllResourcesPage(null, null); + } + + @Override + protected SearchAllResourcesPage createPage( + PageContext + context, + SearchAllResourcesResponse response) { + return new SearchAllResourcesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext + context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class SearchAllResourcesFixedSizeCollection + extends AbstractFixedSizeCollection< + SearchAllResourcesRequest, + SearchAllResourcesResponse, + ResourceSearchResult, + SearchAllResourcesPage, + SearchAllResourcesFixedSizeCollection> { + + private SearchAllResourcesFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static SearchAllResourcesFixedSizeCollection createEmptyCollection() { + return new SearchAllResourcesFixedSizeCollection(null, 0); + } + + @Override + protected SearchAllResourcesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new SearchAllResourcesFixedSizeCollection(pages, collectionSize); + } + } + + public static class SearchAllIamPoliciesPagedResponse + extends AbstractPagedListResponse< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + IamPolicySearchResult, + SearchAllIamPoliciesPage, + SearchAllIamPoliciesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext< + SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> + context, + ApiFuture futureResponse) { + ApiFuture futurePage = + SearchAllIamPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public SearchAllIamPoliciesPagedResponse apply(SearchAllIamPoliciesPage input) { + return new SearchAllIamPoliciesPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private SearchAllIamPoliciesPagedResponse(SearchAllIamPoliciesPage page) { + super(page, SearchAllIamPoliciesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class SearchAllIamPoliciesPage + extends AbstractPage< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + IamPolicySearchResult, + SearchAllIamPoliciesPage> { + + private SearchAllIamPoliciesPage( + PageContext< + SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> + context, + SearchAllIamPoliciesResponse response) { + super(context, response); + } + + private static SearchAllIamPoliciesPage createEmptyPage() { + return new SearchAllIamPoliciesPage(null, null); + } + + @Override + protected SearchAllIamPoliciesPage createPage( + PageContext< + SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> + context, + SearchAllIamPoliciesResponse response) { + return new SearchAllIamPoliciesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext< + SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> + context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class SearchAllIamPoliciesFixedSizeCollection + extends AbstractFixedSizeCollection< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + IamPolicySearchResult, + SearchAllIamPoliciesPage, + SearchAllIamPoliciesFixedSizeCollection> { + + private SearchAllIamPoliciesFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static SearchAllIamPoliciesFixedSizeCollection createEmptyCollection() { + return new SearchAllIamPoliciesFixedSizeCollection(null, 0); + } + + @Override + protected SearchAllIamPoliciesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new SearchAllIamPoliciesFixedSizeCollection(pages, collectionSize); + } + } } diff --git a/test/integration/goldens/asset/AssetServiceClientTest.java b/test/integration/goldens/asset/AssetServiceClientTest.java index 2bcb165008..f12688c9d7 100644 --- a/test/integration/goldens/asset/AssetServiceClientTest.java +++ b/test/integration/goldens/asset/AssetServiceClientTest.java @@ -14,7 +14,10 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1; +package com.google.cloud.asset.v1; + +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GaxGrpcProperties; @@ -24,10 +27,13 @@ import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.InvalidArgumentException; import com.google.api.gax.rpc.StatusCode; +import com.google.common.collect.Lists; import com.google.longrunning.Operation; import com.google.protobuf.AbstractMessage; import com.google.protobuf.Any; +import com.google.protobuf.Empty; import com.google.protobuf.Timestamp; +import com.google.type.Expr; import io.grpc.StatusRuntimeException; import java.io.IOException; import java.util.ArrayList; @@ -87,6 +93,7 @@ public void exportAssetsTest() throws Exception { ExportAssetsResponse.newBuilder() .setReadTime(Timestamp.newBuilder().build()) .setOutputConfig(OutputConfig.newBuilder().build()) + .setOutputResult(OutputResult.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -98,7 +105,7 @@ public void exportAssetsTest() throws Exception { ExportAssetsRequest request = ExportAssetsRequest.newBuilder() - .setParent("ExportAssetsRequest-846449128".toString()) + .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) .setReadTime(Timestamp.newBuilder().build()) .addAllAssetTypes(new ArrayList()) .setOutputConfig(OutputConfig.newBuilder().build()) @@ -130,7 +137,7 @@ public void exportAssetsExceptionTest() throws Exception { try { ExportAssetsRequest request = ExportAssetsRequest.newBuilder() - .setParent("ExportAssetsRequest-846449128".toString()) + .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) .setReadTime(Timestamp.newBuilder().build()) .addAllAssetTypes(new ArrayList()) .setOutputConfig(OutputConfig.newBuilder().build()) @@ -154,7 +161,7 @@ public void batchGetAssetsHistoryTest() throws Exception { BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder() - .setParent("BatchGetAssetsHistoryRequest1575208378".toString()) + .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) .addAllAssetNames(new ArrayList()) .setReadTimeWindow(TimeWindow.newBuilder().build()) .build(); @@ -185,7 +192,7 @@ public void batchGetAssetsHistoryExceptionTest() throws Exception { try { BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder() - .setParent("BatchGetAssetsHistoryRequest1575208378".toString()) + .setParent(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) .addAllAssetNames(new ArrayList()) .setReadTimeWindow(TimeWindow.newBuilder().build()) .build(); @@ -195,4 +202,375 @@ public void batchGetAssetsHistoryExceptionTest() throws Exception { // Expected exception. } } + + @Test + public void createFeedTest() throws Exception { + Feed expectedResponse = + Feed.newBuilder() + .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) + .addAllAssetNames(new ArrayList()) + .addAllAssetTypes(new ArrayList()) + .setFeedOutputConfig(FeedOutputConfig.newBuilder().build()) + .setCondition(Expr.newBuilder().build()) + .build(); + mockAssetService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + Feed actualResponse = client.createFeed(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateFeedRequest actualRequest = ((CreateFeedRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createFeedExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + String parent = "parent-995424086"; + client.createFeed(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFeedTest() throws Exception { + Feed expectedResponse = + Feed.newBuilder() + .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) + .addAllAssetNames(new ArrayList()) + .addAllAssetTypes(new ArrayList()) + .setFeedOutputConfig(FeedOutputConfig.newBuilder().build()) + .setCondition(Expr.newBuilder().build()) + .build(); + mockAssetService.addResponse(expectedResponse); + + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + + Feed actualResponse = client.getFeed(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetFeedRequest actualRequest = ((GetFeedRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getFeedExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + client.getFeed(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getFeedTest2() throws Exception { + Feed expectedResponse = + Feed.newBuilder() + .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) + .addAllAssetNames(new ArrayList()) + .addAllAssetTypes(new ArrayList()) + .setFeedOutputConfig(FeedOutputConfig.newBuilder().build()) + .setCondition(Expr.newBuilder().build()) + .build(); + mockAssetService.addResponse(expectedResponse); + + String name = "name3373707"; + + Feed actualResponse = client.getFeed(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetFeedRequest actualRequest = ((GetFeedRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getFeedExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + String name = "name3373707"; + client.getFeed(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listFeedsTest() throws Exception { + ListFeedsResponse expectedResponse = + ListFeedsResponse.newBuilder().addAllFeeds(new ArrayList()).build(); + mockAssetService.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListFeedsResponse actualResponse = client.listFeeds(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListFeedsRequest actualRequest = ((ListFeedsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listFeedsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + String parent = "parent-995424086"; + client.listFeeds(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateFeedTest() throws Exception { + Feed expectedResponse = + Feed.newBuilder() + .setName(FeedName.ofProjectFeedName("[PROJECT]", "[FEED]").toString()) + .addAllAssetNames(new ArrayList()) + .addAllAssetTypes(new ArrayList()) + .setFeedOutputConfig(FeedOutputConfig.newBuilder().build()) + .setCondition(Expr.newBuilder().build()) + .build(); + mockAssetService.addResponse(expectedResponse); + + Feed feed = Feed.newBuilder().build(); + + Feed actualResponse = client.updateFeed(feed); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateFeedRequest actualRequest = ((UpdateFeedRequest) actualRequests.get(0)); + + Assert.assertEquals(feed, actualRequest.getFeed()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updateFeedExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + Feed feed = Feed.newBuilder().build(); + client.updateFeed(feed); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteFeedTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockAssetService.addResponse(expectedResponse); + + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + + client.deleteFeed(name); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteFeedRequest actualRequest = ((DeleteFeedRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteFeedExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + client.deleteFeed(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteFeedTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockAssetService.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteFeed(name); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteFeedRequest actualRequest = ((DeleteFeedRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteFeedExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + String name = "name3373707"; + client.deleteFeed(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchAllResourcesTest() throws Exception { + ResourceSearchResult responsesElement = ResourceSearchResult.newBuilder().build(); + SearchAllResourcesResponse expectedResponse = + SearchAllResourcesResponse.newBuilder() + .setNextPageToken("") + .addAllResults(Arrays.asList(responsesElement)) + .build(); + mockAssetService.addResponse(expectedResponse); + + String scope = "scope109264468"; + String query = "query107944136"; + List assetTypes = new ArrayList<>(); + + SearchAllResourcesPagedResponse pagedListResponse = + client.searchAllResources(scope, query, assetTypes); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + SearchAllResourcesRequest actualRequest = ((SearchAllResourcesRequest) actualRequests.get(0)); + + Assert.assertEquals(scope, actualRequest.getScope()); + Assert.assertEquals(query, actualRequest.getQuery()); + Assert.assertEquals(assetTypes, actualRequest.getAssetTypesList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void searchAllResourcesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + String scope = "scope109264468"; + String query = "query107944136"; + List assetTypes = new ArrayList<>(); + client.searchAllResources(scope, query, assetTypes); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void searchAllIamPoliciesTest() throws Exception { + IamPolicySearchResult responsesElement = IamPolicySearchResult.newBuilder().build(); + SearchAllIamPoliciesResponse expectedResponse = + SearchAllIamPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllResults(Arrays.asList(responsesElement)) + .build(); + mockAssetService.addResponse(expectedResponse); + + String scope = "scope109264468"; + String query = "query107944136"; + + SearchAllIamPoliciesPagedResponse pagedListResponse = client.searchAllIamPolicies(scope, query); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResultsList().get(0), resources.get(0)); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + SearchAllIamPoliciesRequest actualRequest = + ((SearchAllIamPoliciesRequest) actualRequests.get(0)); + + Assert.assertEquals(scope, actualRequest.getScope()); + Assert.assertEquals(query, actualRequest.getQuery()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void searchAllIamPoliciesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + String scope = "scope109264468"; + String query = "query107944136"; + client.searchAllIamPolicies(scope, query); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/test/integration/goldens/asset/AssetServiceSettings.java b/test/integration/goldens/asset/AssetServiceSettings.java index 3b6c7817dd..be010b730a 100644 --- a/test/integration/goldens/asset/AssetServiceSettings.java +++ b/test/integration/goldens/asset/AssetServiceSettings.java @@ -14,7 +14,10 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1; +package com.google.cloud.asset.v1; + +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; @@ -25,11 +28,13 @@ import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PagedCallSettings; import com.google.api.gax.rpc.StubSettings; import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.asset.v1beta1.stub.AssetServiceStubSettings; +import com.google.cloud.asset.v1.stub.AssetServiceStubSettings; import com.google.longrunning.Operation; +import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; import javax.annotation.Generated; @@ -65,7 +70,6 @@ * AssetServiceSettings assetServiceSettings = assetServiceSettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class AssetServiceSettings extends ClientSettings { @@ -86,6 +90,47 @@ public UnaryCallSettings exportAssetsSettings() return ((AssetServiceStubSettings) getStubSettings()).batchGetAssetsHistorySettings(); } + /** Returns the object with the settings used for calls to createFeed. */ + public UnaryCallSettings createFeedSettings() { + return ((AssetServiceStubSettings) getStubSettings()).createFeedSettings(); + } + + /** Returns the object with the settings used for calls to getFeed. */ + public UnaryCallSettings getFeedSettings() { + return ((AssetServiceStubSettings) getStubSettings()).getFeedSettings(); + } + + /** Returns the object with the settings used for calls to listFeeds. */ + public UnaryCallSettings listFeedsSettings() { + return ((AssetServiceStubSettings) getStubSettings()).listFeedsSettings(); + } + + /** Returns the object with the settings used for calls to updateFeed. */ + public UnaryCallSettings updateFeedSettings() { + return ((AssetServiceStubSettings) getStubSettings()).updateFeedSettings(); + } + + /** Returns the object with the settings used for calls to deleteFeed. */ + public UnaryCallSettings deleteFeedSettings() { + return ((AssetServiceStubSettings) getStubSettings()).deleteFeedSettings(); + } + + /** Returns the object with the settings used for calls to searchAllResources. */ + public PagedCallSettings< + SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> + searchAllResourcesSettings() { + return ((AssetServiceStubSettings) getStubSettings()).searchAllResourcesSettings(); + } + + /** Returns the object with the settings used for calls to searchAllIamPolicies. */ + public PagedCallSettings< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + SearchAllIamPoliciesPagedResponse> + searchAllIamPoliciesSettings() { + return ((AssetServiceStubSettings) getStubSettings()).searchAllIamPoliciesSettings(); + } + public static final AssetServiceSettings create(AssetServiceStubSettings stub) throws IOException { return new AssetServiceSettings.Builder(stub.toBuilder()).build(); @@ -202,6 +247,47 @@ public UnaryCallSettings.Builder exportAssetsSet return getStubSettingsBuilder().batchGetAssetsHistorySettings(); } + /** Returns the builder for the settings used for calls to createFeed. */ + public UnaryCallSettings.Builder createFeedSettings() { + return getStubSettingsBuilder().createFeedSettings(); + } + + /** Returns the builder for the settings used for calls to getFeed. */ + public UnaryCallSettings.Builder getFeedSettings() { + return getStubSettingsBuilder().getFeedSettings(); + } + + /** Returns the builder for the settings used for calls to listFeeds. */ + public UnaryCallSettings.Builder listFeedsSettings() { + return getStubSettingsBuilder().listFeedsSettings(); + } + + /** Returns the builder for the settings used for calls to updateFeed. */ + public UnaryCallSettings.Builder updateFeedSettings() { + return getStubSettingsBuilder().updateFeedSettings(); + } + + /** Returns the builder for the settings used for calls to deleteFeed. */ + public UnaryCallSettings.Builder deleteFeedSettings() { + return getStubSettingsBuilder().deleteFeedSettings(); + } + + /** Returns the builder for the settings used for calls to searchAllResources. */ + public PagedCallSettings.Builder< + SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> + searchAllResourcesSettings() { + return getStubSettingsBuilder().searchAllResourcesSettings(); + } + + /** Returns the builder for the settings used for calls to searchAllIamPolicies. */ + public PagedCallSettings.Builder< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + SearchAllIamPoliciesPagedResponse> + searchAllIamPoliciesSettings() { + return getStubSettingsBuilder().searchAllIamPoliciesSettings(); + } + @Override public AssetServiceSettings build() throws IOException { return new AssetServiceSettings(this); diff --git a/test/integration/goldens/asset/AssetServiceStub.java b/test/integration/goldens/asset/AssetServiceStub.java index 27dc91eb21..274dfb3911 100644 --- a/test/integration/goldens/asset/AssetServiceStub.java +++ b/test/integration/goldens/asset/AssetServiceStub.java @@ -14,18 +14,32 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1.stub; +package com.google.cloud.asset.v1.stub; + +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryRequest; -import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryResponse; -import com.google.cloud.asset.v1beta1.ExportAssetsRequest; -import com.google.cloud.asset.v1beta1.ExportAssetsResponse; +import com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest; +import com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse; +import com.google.cloud.asset.v1.CreateFeedRequest; +import com.google.cloud.asset.v1.DeleteFeedRequest; +import com.google.cloud.asset.v1.ExportAssetsRequest; +import com.google.cloud.asset.v1.ExportAssetsResponse; +import com.google.cloud.asset.v1.Feed; +import com.google.cloud.asset.v1.GetFeedRequest; +import com.google.cloud.asset.v1.ListFeedsRequest; +import com.google.cloud.asset.v1.ListFeedsResponse; +import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest; +import com.google.cloud.asset.v1.SearchAllIamPoliciesResponse; +import com.google.cloud.asset.v1.SearchAllResourcesRequest; +import com.google.cloud.asset.v1.SearchAllResourcesResponse; +import com.google.cloud.asset.v1.UpdateFeedRequest; import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; +import com.google.protobuf.Empty; import javax.annotation.Generated; // AUTO-GENERATED DOCUMENTATION AND CLASS. @@ -34,7 +48,6 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@BetaApi @Generated("by gapic-generator-java") public abstract class AssetServiceStub implements BackgroundResource { @@ -56,6 +69,46 @@ public UnaryCallable exportAssetsCallable() { throw new UnsupportedOperationException("Not implemented: batchGetAssetsHistoryCallable()"); } + public UnaryCallable createFeedCallable() { + throw new UnsupportedOperationException("Not implemented: createFeedCallable()"); + } + + public UnaryCallable getFeedCallable() { + throw new UnsupportedOperationException("Not implemented: getFeedCallable()"); + } + + public UnaryCallable listFeedsCallable() { + throw new UnsupportedOperationException("Not implemented: listFeedsCallable()"); + } + + public UnaryCallable updateFeedCallable() { + throw new UnsupportedOperationException("Not implemented: updateFeedCallable()"); + } + + public UnaryCallable deleteFeedCallable() { + throw new UnsupportedOperationException("Not implemented: deleteFeedCallable()"); + } + + public UnaryCallable + searchAllResourcesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: searchAllResourcesPagedCallable()"); + } + + public UnaryCallable + searchAllResourcesCallable() { + throw new UnsupportedOperationException("Not implemented: searchAllResourcesCallable()"); + } + + public UnaryCallable + searchAllIamPoliciesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: searchAllIamPoliciesPagedCallable()"); + } + + public UnaryCallable + searchAllIamPoliciesCallable() { + throw new UnsupportedOperationException("Not implemented: searchAllIamPoliciesCallable()"); + } + @Override public abstract void close(); } diff --git a/test/integration/goldens/asset/AssetServiceStubSettings.java b/test/integration/goldens/asset/AssetServiceStubSettings.java index 79c8b3191e..6b6094255d 100644 --- a/test/integration/goldens/asset/AssetServiceStubSettings.java +++ b/test/integration/goldens/asset/AssetServiceStubSettings.java @@ -14,9 +14,13 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1.stub; +package com.google.cloud.asset.v1.stub; + +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; import com.google.api.core.BetaApi; import com.google.api.gax.core.GaxProperties; import com.google.api.gax.core.GoogleCredentialsProvider; @@ -28,22 +32,42 @@ import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; import com.google.api.gax.rpc.StatusCode; import com.google.api.gax.rpc.StubSettings; import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryRequest; -import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryResponse; -import com.google.cloud.asset.v1beta1.ExportAssetsRequest; -import com.google.cloud.asset.v1beta1.ExportAssetsResponse; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest; +import com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse; +import com.google.cloud.asset.v1.CreateFeedRequest; +import com.google.cloud.asset.v1.DeleteFeedRequest; +import com.google.cloud.asset.v1.ExportAssetsRequest; +import com.google.cloud.asset.v1.ExportAssetsResponse; +import com.google.cloud.asset.v1.Feed; +import com.google.cloud.asset.v1.GetFeedRequest; +import com.google.cloud.asset.v1.IamPolicySearchResult; +import com.google.cloud.asset.v1.ListFeedsRequest; +import com.google.cloud.asset.v1.ListFeedsResponse; +import com.google.cloud.asset.v1.ResourceSearchResult; +import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest; +import com.google.cloud.asset.v1.SearchAllIamPoliciesResponse; +import com.google.cloud.asset.v1.SearchAllResourcesRequest; +import com.google.cloud.asset.v1.SearchAllResourcesResponse; +import com.google.cloud.asset.v1.UpdateFeedRequest; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.longrunning.Operation; +import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; import javax.annotation.Generated; @@ -81,7 +105,6 @@ * AssetServiceStubSettings assetServiceSettings = assetServiceSettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class AssetServiceStubSettings extends StubSettings { /** The default scopes of the service. */ @@ -94,6 +117,149 @@ public class AssetServiceStubSettings extends StubSettings batchGetAssetsHistorySettings; + private final UnaryCallSettings createFeedSettings; + private final UnaryCallSettings getFeedSettings; + private final UnaryCallSettings listFeedsSettings; + private final UnaryCallSettings updateFeedSettings; + private final UnaryCallSettings deleteFeedSettings; + private final PagedCallSettings< + SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> + searchAllResourcesSettings; + private final PagedCallSettings< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + SearchAllIamPoliciesPagedResponse> + searchAllIamPoliciesSettings; + + private static final PagedListDescriptor< + SearchAllResourcesRequest, SearchAllResourcesResponse, ResourceSearchResult> + SEARCH_ALL_RESOURCES_PAGE_STR_DESC = + new PagedListDescriptor< + SearchAllResourcesRequest, SearchAllResourcesResponse, ResourceSearchResult>() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public SearchAllResourcesRequest injectToken( + SearchAllResourcesRequest payload, String token) { + return SearchAllResourcesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public SearchAllResourcesRequest injectPageSize( + SearchAllResourcesRequest payload, int pageSize) { + return SearchAllResourcesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(SearchAllResourcesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(SearchAllResourcesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources( + SearchAllResourcesResponse payload) { + return payload.getResultsList() == null + ? ImmutableList.of() + : payload.getResultsList(); + } + }; + + private static final PagedListDescriptor< + SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult> + SEARCH_ALL_IAM_POLICIES_PAGE_STR_DESC = + new PagedListDescriptor< + SearchAllIamPoliciesRequest, SearchAllIamPoliciesResponse, IamPolicySearchResult>() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public SearchAllIamPoliciesRequest injectToken( + SearchAllIamPoliciesRequest payload, String token) { + return SearchAllIamPoliciesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public SearchAllIamPoliciesRequest injectPageSize( + SearchAllIamPoliciesRequest payload, int pageSize) { + return SearchAllIamPoliciesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(SearchAllIamPoliciesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(SearchAllIamPoliciesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources( + SearchAllIamPoliciesResponse payload) { + return payload.getResultsList() == null + ? ImmutableList.of() + : payload.getResultsList(); + } + }; + + private static final PagedListResponseFactory< + SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> + SEARCH_ALL_RESOURCES_PAGE_STR_FACT = + new PagedListResponseFactory< + SearchAllResourcesRequest, + SearchAllResourcesResponse, + SearchAllResourcesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + SearchAllResourcesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext< + SearchAllResourcesRequest, SearchAllResourcesResponse, ResourceSearchResult> + pageContext = + PageContext.create( + callable, SEARCH_ALL_RESOURCES_PAGE_STR_DESC, request, context); + return SearchAllResourcesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + SearchAllIamPoliciesPagedResponse> + SEARCH_ALL_IAM_POLICIES_PAGE_STR_FACT = + new PagedListResponseFactory< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + SearchAllIamPoliciesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + SearchAllIamPoliciesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + IamPolicySearchResult> + pageContext = + PageContext.create( + callable, SEARCH_ALL_IAM_POLICIES_PAGE_STR_DESC, request, context); + return SearchAllIamPoliciesPagedResponse.createAsync(pageContext, futureResponse); + } + }; /** Returns the object with the settings used for calls to exportAssets. */ public UnaryCallSettings exportAssetsSettings() { @@ -112,6 +278,47 @@ public UnaryCallSettings exportAssetsSettings() return batchGetAssetsHistorySettings; } + /** Returns the object with the settings used for calls to createFeed. */ + public UnaryCallSettings createFeedSettings() { + return createFeedSettings; + } + + /** Returns the object with the settings used for calls to getFeed. */ + public UnaryCallSettings getFeedSettings() { + return getFeedSettings; + } + + /** Returns the object with the settings used for calls to listFeeds. */ + public UnaryCallSettings listFeedsSettings() { + return listFeedsSettings; + } + + /** Returns the object with the settings used for calls to updateFeed. */ + public UnaryCallSettings updateFeedSettings() { + return updateFeedSettings; + } + + /** Returns the object with the settings used for calls to deleteFeed. */ + public UnaryCallSettings deleteFeedSettings() { + return deleteFeedSettings; + } + + /** Returns the object with the settings used for calls to searchAllResources. */ + public PagedCallSettings< + SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> + searchAllResourcesSettings() { + return searchAllResourcesSettings; + } + + /** Returns the object with the settings used for calls to searchAllIamPolicies. */ + public PagedCallSettings< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + SearchAllIamPoliciesPagedResponse> + searchAllIamPoliciesSettings() { + return searchAllIamPoliciesSettings; + } + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public AssetServiceStub createStub() throws IOException { if (getTransportChannelProvider() @@ -184,6 +391,13 @@ protected AssetServiceStubSettings(Builder settingsBuilder) throws IOException { exportAssetsSettings = settingsBuilder.exportAssetsSettings().build(); exportAssetsOperationSettings = settingsBuilder.exportAssetsOperationSettings().build(); batchGetAssetsHistorySettings = settingsBuilder.batchGetAssetsHistorySettings().build(); + createFeedSettings = settingsBuilder.createFeedSettings().build(); + getFeedSettings = settingsBuilder.getFeedSettings().build(); + listFeedsSettings = settingsBuilder.listFeedsSettings().build(); + updateFeedSettings = settingsBuilder.updateFeedSettings().build(); + deleteFeedSettings = settingsBuilder.deleteFeedSettings().build(); + searchAllResourcesSettings = settingsBuilder.searchAllResourcesSettings().build(); + searchAllIamPoliciesSettings = settingsBuilder.searchAllIamPoliciesSettings().build(); } /** Builder for AssetServiceStubSettings. */ @@ -196,6 +410,19 @@ public static class Builder extends StubSettings.Builder batchGetAssetsHistorySettings; + private final UnaryCallSettings.Builder createFeedSettings; + private final UnaryCallSettings.Builder getFeedSettings; + private final UnaryCallSettings.Builder listFeedsSettings; + private final UnaryCallSettings.Builder updateFeedSettings; + private final UnaryCallSettings.Builder deleteFeedSettings; + private final PagedCallSettings.Builder< + SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> + searchAllResourcesSettings; + private final PagedCallSettings.Builder< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + SearchAllIamPoliciesPagedResponse> + searchAllIamPoliciesSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -209,6 +436,11 @@ public static class Builder extends StubSettings.BuildernewArrayList( StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put( + "retry_policy_2_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -236,6 +468,17 @@ public static class Builder extends StubSettings.Builder>of( - exportAssetsSettings, batchGetAssetsHistorySettings); + exportAssetsSettings, + batchGetAssetsHistorySettings, + createFeedSettings, + getFeedSettings, + listFeedsSettings, + updateFeedSettings, + deleteFeedSettings, + searchAllResourcesSettings, + searchAllIamPoliciesSettings); initDefaults(this); } @@ -262,10 +521,25 @@ protected Builder(AssetServiceStubSettings settings) { exportAssetsSettings = settings.exportAssetsSettings.toBuilder(); exportAssetsOperationSettings = settings.exportAssetsOperationSettings.toBuilder(); batchGetAssetsHistorySettings = settings.batchGetAssetsHistorySettings.toBuilder(); + createFeedSettings = settings.createFeedSettings.toBuilder(); + getFeedSettings = settings.getFeedSettings.toBuilder(); + listFeedsSettings = settings.listFeedsSettings.toBuilder(); + updateFeedSettings = settings.updateFeedSettings.toBuilder(); + deleteFeedSettings = settings.deleteFeedSettings.toBuilder(); + searchAllResourcesSettings = settings.searchAllResourcesSettings.toBuilder(); + searchAllIamPoliciesSettings = settings.searchAllIamPoliciesSettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( - exportAssetsSettings, batchGetAssetsHistorySettings); + exportAssetsSettings, + batchGetAssetsHistorySettings, + createFeedSettings, + getFeedSettings, + listFeedsSettings, + updateFeedSettings, + deleteFeedSettings, + searchAllResourcesSettings, + searchAllIamPoliciesSettings); } private static Builder createDefault() { @@ -290,6 +564,41 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + builder + .createFeedSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + + builder + .getFeedSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .listFeedsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .updateFeedSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + + builder + .deleteFeedSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .searchAllResourcesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + + builder + .searchAllIamPoliciesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params")); + builder .exportAssetsOperationSettings() .setInitialCallSettings( @@ -353,6 +662,47 @@ public UnaryCallSettings.Builder exportAssetsSet return batchGetAssetsHistorySettings; } + /** Returns the builder for the settings used for calls to createFeed. */ + public UnaryCallSettings.Builder createFeedSettings() { + return createFeedSettings; + } + + /** Returns the builder for the settings used for calls to getFeed. */ + public UnaryCallSettings.Builder getFeedSettings() { + return getFeedSettings; + } + + /** Returns the builder for the settings used for calls to listFeeds. */ + public UnaryCallSettings.Builder listFeedsSettings() { + return listFeedsSettings; + } + + /** Returns the builder for the settings used for calls to updateFeed. */ + public UnaryCallSettings.Builder updateFeedSettings() { + return updateFeedSettings; + } + + /** Returns the builder for the settings used for calls to deleteFeed. */ + public UnaryCallSettings.Builder deleteFeedSettings() { + return deleteFeedSettings; + } + + /** Returns the builder for the settings used for calls to searchAllResources. */ + public PagedCallSettings.Builder< + SearchAllResourcesRequest, SearchAllResourcesResponse, SearchAllResourcesPagedResponse> + searchAllResourcesSettings() { + return searchAllResourcesSettings; + } + + /** Returns the builder for the settings used for calls to searchAllIamPolicies. */ + public PagedCallSettings.Builder< + SearchAllIamPoliciesRequest, + SearchAllIamPoliciesResponse, + SearchAllIamPoliciesPagedResponse> + searchAllIamPoliciesSettings() { + return searchAllIamPoliciesSettings; + } + @Override public AssetServiceStubSettings build() throws IOException { return new AssetServiceStubSettings(this); diff --git a/test/integration/goldens/asset/FeedName.java b/test/integration/goldens/asset/FeedName.java new file mode 100644 index 0000000000..b9e600c37d --- /dev/null +++ b/test/integration/goldens/asset/FeedName.java @@ -0,0 +1,368 @@ +/* + * Copyright 2020 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.asset.v1; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class FeedName implements ResourceName { + private static final PathTemplate PROJECT_FEED = + PathTemplate.createWithoutUrlEncoding("projects/{project}/feeds/{feed}"); + private static final PathTemplate FOLDER_FEED = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/feeds/{feed}"); + private static final PathTemplate ORGANIZATION_FEED = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}/feeds/{feed}"); + private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; + private final String project; + private final String feed; + private final String folder; + private final String organization; + + @Deprecated + protected FeedName() { + project = null; + feed = null; + folder = null; + organization = null; + } + + private FeedName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + feed = Preconditions.checkNotNull(builder.getFeed()); + folder = null; + organization = null; + pathTemplate = PROJECT_FEED; + } + + private FeedName(FolderFeedBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + feed = Preconditions.checkNotNull(builder.getFeed()); + project = null; + organization = null; + pathTemplate = FOLDER_FEED; + } + + private FeedName(OrganizationFeedBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + feed = Preconditions.checkNotNull(builder.getFeed()); + project = null; + folder = null; + pathTemplate = ORGANIZATION_FEED; + } + + public String getProject() { + return project; + } + + public String getFeed() { + return feed; + } + + public String getFolder() { + return folder; + } + + public String getOrganization() { + return organization; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectFeedBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderFeedBuilder newFolderFeedBuilder() { + return new FolderFeedBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationFeedBuilder newOrganizationFeedBuilder() { + return new OrganizationFeedBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static FeedName of(String project, String feed) { + return newBuilder().setProject(project).setFeed(feed).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static FeedName ofProjectFeedName(String project, String feed) { + return newBuilder().setProject(project).setFeed(feed).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static FeedName ofFolderFeedName(String folder, String feed) { + return newFolderFeedBuilder().setFolder(folder).setFeed(feed).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static FeedName ofOrganizationFeedName(String organization, String feed) { + return newOrganizationFeedBuilder().setOrganization(organization).setFeed(feed).build(); + } + + public static String format(String project, String feed) { + return newBuilder().setProject(project).setFeed(feed).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectFeedName(String project, String feed) { + return newBuilder().setProject(project).setFeed(feed).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderFeedName(String folder, String feed) { + return newFolderFeedBuilder().setFolder(folder).setFeed(feed).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationFeedName(String organization, String feed) { + return newOrganizationFeedBuilder() + .setOrganization(organization) + .setFeed(feed) + .build() + .toString(); + } + + public static FeedName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + if (PROJECT_FEED.matches(formattedString)) { + Map matchMap = PROJECT_FEED.match(formattedString); + return ofProjectFeedName(matchMap.get("project"), matchMap.get("feed")); + } else if (FOLDER_FEED.matches(formattedString)) { + Map matchMap = FOLDER_FEED.match(formattedString); + return ofFolderFeedName(matchMap.get("folder"), matchMap.get("feed")); + } else if (ORGANIZATION_FEED.matches(formattedString)) { + Map matchMap = ORGANIZATION_FEED.match(formattedString); + return ofOrganizationFeedName(matchMap.get("organization"), matchMap.get("feed")); + } + throw new ValidationException("FeedName.parse: formattedString not in valid format"); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (FeedName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_FEED.matches(formattedString) + || FOLDER_FEED.matches(formattedString) + || ORGANIZATION_FEED.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (feed != null) { + fieldMapBuilder.put("feed", feed); + } + if (folder != null) { + fieldMapBuilder.put("folder", folder); + } + if (organization != null) { + fieldMapBuilder.put("organization", organization); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + FeedName that = ((FeedName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.feed, that.feed) + && Objects.equals(this.folder, that.folder) + && Objects.equals(this.organization, that.organization); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(feed); + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(organization); + return h; + } + + /** Builder for projects/{project}/feeds/{feed}. */ + public static class Builder { + private String project; + private String feed; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getFeed() { + return feed; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setFeed(String feed) { + this.feed = feed; + return this; + } + + private Builder(FeedName feedName) { + Preconditions.checkArgument( + Objects.equals(feedName.pathTemplate, PROJECT_FEED), + "toBuilder is only supported when FeedName has the pattern of projects/{project}/feeds/{feed}"); + project = feedName.project; + feed = feedName.feed; + } + + public FeedName build() { + return new FeedName(this); + } + } + + /** Builder for folders/{folder}/feeds/{feed}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderFeedBuilder { + private String folder; + private String feed; + + protected FolderFeedBuilder() {} + + public String getFolder() { + return folder; + } + + public String getFeed() { + return feed; + } + + public FolderFeedBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public FolderFeedBuilder setFeed(String feed) { + this.feed = feed; + return this; + } + + public FeedName build() { + return new FeedName(this); + } + } + + /** Builder for organizations/{organization}/feeds/{feed}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationFeedBuilder { + private String organization; + private String feed; + + protected OrganizationFeedBuilder() {} + + public String getOrganization() { + return organization; + } + + public String getFeed() { + return feed; + } + + public OrganizationFeedBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public OrganizationFeedBuilder setFeed(String feed) { + this.feed = feed; + return this; + } + + public FeedName build() { + return new FeedName(this); + } + } +} diff --git a/test/integration/goldens/asset/GrpcAssetServiceCallableFactory.java b/test/integration/goldens/asset/GrpcAssetServiceCallableFactory.java index 374934f547..8a3a677c97 100644 --- a/test/integration/goldens/asset/GrpcAssetServiceCallableFactory.java +++ b/test/integration/goldens/asset/GrpcAssetServiceCallableFactory.java @@ -14,9 +14,8 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1.stub; +package com.google.cloud.asset.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -42,7 +41,6 @@ * *

This class is for advanced usage. */ -@BetaApi @Generated("by gapic-generator-java") public class GrpcAssetServiceCallableFactory implements GrpcStubCallableFactory { diff --git a/test/integration/goldens/asset/GrpcAssetServiceStub.java b/test/integration/goldens/asset/GrpcAssetServiceStub.java index 962ca1342c..b613cceb4e 100644 --- a/test/integration/goldens/asset/GrpcAssetServiceStub.java +++ b/test/integration/goldens/asset/GrpcAssetServiceStub.java @@ -14,9 +14,11 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1.stub; +package com.google.cloud.asset.v1.stub; + +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllIamPoliciesPagedResponse; +import static com.google.cloud.asset.v1.AssetServiceClient.SearchAllResourcesPagedResponse; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -25,13 +27,25 @@ import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryRequest; -import com.google.cloud.asset.v1beta1.BatchGetAssetsHistoryResponse; -import com.google.cloud.asset.v1beta1.ExportAssetsRequest; -import com.google.cloud.asset.v1beta1.ExportAssetsResponse; +import com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest; +import com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse; +import com.google.cloud.asset.v1.CreateFeedRequest; +import com.google.cloud.asset.v1.DeleteFeedRequest; +import com.google.cloud.asset.v1.ExportAssetsRequest; +import com.google.cloud.asset.v1.ExportAssetsResponse; +import com.google.cloud.asset.v1.Feed; +import com.google.cloud.asset.v1.GetFeedRequest; +import com.google.cloud.asset.v1.ListFeedsRequest; +import com.google.cloud.asset.v1.ListFeedsResponse; +import com.google.cloud.asset.v1.SearchAllIamPoliciesRequest; +import com.google.cloud.asset.v1.SearchAllIamPoliciesResponse; +import com.google.cloud.asset.v1.SearchAllResourcesRequest; +import com.google.cloud.asset.v1.SearchAllResourcesResponse; +import com.google.cloud.asset.v1.UpdateFeedRequest; import com.google.common.collect.ImmutableMap; import com.google.longrunning.Operation; import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; import io.grpc.MethodDescriptor; import io.grpc.protobuf.ProtoUtils; import java.io.IOException; @@ -45,14 +59,13 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@BetaApi @Generated("by gapic-generator-java") public class GrpcAssetServiceStub extends AssetServiceStub { private static final MethodDescriptor exportAssetsMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1beta1.AssetService/ExportAssets") + .setFullMethodName("google.cloud.asset.v1.AssetService/ExportAssets") .setRequestMarshaller(ProtoUtils.marshaller(ExportAssetsRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); @@ -61,18 +74,94 @@ public class GrpcAssetServiceStub extends AssetServiceStub { batchGetAssetsHistoryMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1beta1.AssetService/BatchGetAssetsHistory") + .setFullMethodName("google.cloud.asset.v1.AssetService/BatchGetAssetsHistory") .setRequestMarshaller( ProtoUtils.marshaller(BatchGetAssetsHistoryRequest.getDefaultInstance())) .setResponseMarshaller( ProtoUtils.marshaller(BatchGetAssetsHistoryResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor createFeedMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.asset.v1.AssetService/CreateFeed") + .setRequestMarshaller(ProtoUtils.marshaller(CreateFeedRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Feed.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getFeedMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.asset.v1.AssetService/GetFeed") + .setRequestMarshaller(ProtoUtils.marshaller(GetFeedRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Feed.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listFeedsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.asset.v1.AssetService/ListFeeds") + .setRequestMarshaller(ProtoUtils.marshaller(ListFeedsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(ListFeedsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor updateFeedMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.asset.v1.AssetService/UpdateFeed") + .setRequestMarshaller(ProtoUtils.marshaller(UpdateFeedRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Feed.getDefaultInstance())) + .build(); + + private static final MethodDescriptor deleteFeedMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.asset.v1.AssetService/DeleteFeed") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteFeedRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + searchAllResourcesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.asset.v1.AssetService/SearchAllResources") + .setRequestMarshaller( + ProtoUtils.marshaller(SearchAllResourcesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(SearchAllResourcesResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + searchAllIamPoliciesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.asset.v1.AssetService/SearchAllIamPolicies") + .setRequestMarshaller( + ProtoUtils.marshaller(SearchAllIamPoliciesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(SearchAllIamPoliciesResponse.getDefaultInstance())) + .build(); + private final UnaryCallable exportAssetsCallable; private final OperationCallable exportAssetsOperationCallable; private final UnaryCallable batchGetAssetsHistoryCallable; + private final UnaryCallable createFeedCallable; + private final UnaryCallable getFeedCallable; + private final UnaryCallable listFeedsCallable; + private final UnaryCallable updateFeedCallable; + private final UnaryCallable deleteFeedCallable; + private final UnaryCallable + searchAllResourcesCallable; + private final UnaryCallable + searchAllResourcesPagedCallable; + private final UnaryCallable + searchAllIamPoliciesCallable; + private final UnaryCallable + searchAllIamPoliciesPagedCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; @@ -144,6 +233,99 @@ public Map extract(BatchGetAssetsHistoryRequest request) { } }) .build(); + GrpcCallSettings createFeedTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createFeedMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(CreateFeedRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getFeedTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getFeedMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetFeedRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings listFeedsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listFeedsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListFeedsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings updateFeedTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateFeedMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdateFeedRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("feed.name", String.valueOf(request.getFeed().getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings deleteFeedTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteFeedMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(DeleteFeedRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings + searchAllResourcesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(searchAllResourcesMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(SearchAllResourcesRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("scope", String.valueOf(request.getScope())); + return params.build(); + } + }) + .build(); + GrpcCallSettings + searchAllIamPoliciesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(searchAllIamPoliciesMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(SearchAllIamPoliciesRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("scope", String.valueOf(request.getScope())); + return params.build(); + } + }) + .build(); this.exportAssetsCallable = callableFactory.createUnaryCallable( @@ -159,6 +341,41 @@ public Map extract(BatchGetAssetsHistoryRequest request) { batchGetAssetsHistoryTransportSettings, settings.batchGetAssetsHistorySettings(), clientContext); + this.createFeedCallable = + callableFactory.createUnaryCallable( + createFeedTransportSettings, settings.createFeedSettings(), clientContext); + this.getFeedCallable = + callableFactory.createUnaryCallable( + getFeedTransportSettings, settings.getFeedSettings(), clientContext); + this.listFeedsCallable = + callableFactory.createUnaryCallable( + listFeedsTransportSettings, settings.listFeedsSettings(), clientContext); + this.updateFeedCallable = + callableFactory.createUnaryCallable( + updateFeedTransportSettings, settings.updateFeedSettings(), clientContext); + this.deleteFeedCallable = + callableFactory.createUnaryCallable( + deleteFeedTransportSettings, settings.deleteFeedSettings(), clientContext); + this.searchAllResourcesCallable = + callableFactory.createUnaryCallable( + searchAllResourcesTransportSettings, + settings.searchAllResourcesSettings(), + clientContext); + this.searchAllResourcesPagedCallable = + callableFactory.createPagedCallable( + searchAllResourcesTransportSettings, + settings.searchAllResourcesSettings(), + clientContext); + this.searchAllIamPoliciesCallable = + callableFactory.createUnaryCallable( + searchAllIamPoliciesTransportSettings, + settings.searchAllIamPoliciesSettings(), + clientContext); + this.searchAllIamPoliciesPagedCallable = + callableFactory.createPagedCallable( + searchAllIamPoliciesTransportSettings, + settings.searchAllIamPoliciesSettings(), + clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -182,6 +399,46 @@ public UnaryCallable exportAssetsCallable() { return batchGetAssetsHistoryCallable; } + public UnaryCallable createFeedCallable() { + return createFeedCallable; + } + + public UnaryCallable getFeedCallable() { + return getFeedCallable; + } + + public UnaryCallable listFeedsCallable() { + return listFeedsCallable; + } + + public UnaryCallable updateFeedCallable() { + return updateFeedCallable; + } + + public UnaryCallable deleteFeedCallable() { + return deleteFeedCallable; + } + + public UnaryCallable + searchAllResourcesCallable() { + return searchAllResourcesCallable; + } + + public UnaryCallable + searchAllResourcesPagedCallable() { + return searchAllResourcesPagedCallable; + } + + public UnaryCallable + searchAllIamPoliciesCallable() { + return searchAllIamPoliciesCallable; + } + + public UnaryCallable + searchAllIamPoliciesPagedCallable() { + return searchAllIamPoliciesPagedCallable; + } + @Override public final void close() { shutdown(); diff --git a/test/integration/goldens/asset/MockAssetService.java b/test/integration/goldens/asset/MockAssetService.java index b7022c2b57..140e701a9e 100644 --- a/test/integration/goldens/asset/MockAssetService.java +++ b/test/integration/goldens/asset/MockAssetService.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1; +package com.google.cloud.asset.v1; import com.google.api.core.BetaApi; import com.google.api.gax.grpc.testing.MockGrpcService; diff --git a/test/integration/goldens/asset/MockAssetServiceImpl.java b/test/integration/goldens/asset/MockAssetServiceImpl.java index 279e8a2c43..1ef582b272 100644 --- a/test/integration/goldens/asset/MockAssetServiceImpl.java +++ b/test/integration/goldens/asset/MockAssetServiceImpl.java @@ -14,12 +14,13 @@ * limitations under the License. */ -package com.google.cloud.asset.v1beta1; +package com.google.cloud.asset.v1; import com.google.api.core.BetaApi; -import com.google.cloud.asset.v1beta1.AssetServiceGrpc.AssetServiceImplBase; +import com.google.cloud.asset.v1.AssetServiceGrpc.AssetServiceImplBase; import com.google.longrunning.Operation; import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Empty; import io.grpc.stub.StreamObserver; import java.util.ArrayList; import java.util.LinkedList; @@ -89,4 +90,107 @@ public void batchGetAssetsHistory( responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } } + + @Override + public void createFeed(CreateFeedRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Feed) { + requests.add(request); + responseObserver.onNext(((Feed) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void getFeed(GetFeedRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Feed) { + requests.add(request); + responseObserver.onNext(((Feed) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void listFeeds( + ListFeedsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof ListFeedsResponse) { + requests.add(request); + responseObserver.onNext(((ListFeedsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void updateFeed(UpdateFeedRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Feed) { + requests.add(request); + responseObserver.onNext(((Feed) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void deleteFeed(DeleteFeedRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void searchAllResources( + SearchAllResourcesRequest request, + StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof SearchAllResourcesResponse) { + requests.add(request); + responseObserver.onNext(((SearchAllResourcesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } + + @Override + public void searchAllIamPolicies( + SearchAllIamPoliciesRequest request, + StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof SearchAllIamPoliciesResponse) { + requests.add(request); + responseObserver.onNext(((SearchAllIamPoliciesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + } + } } diff --git a/test/integration/goldens/asset/PlaceholderFile.java b/test/integration/goldens/asset/PlaceholderFile.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/integration/goldens/asset/package-info.java b/test/integration/goldens/asset/package-info.java index f889373e0f..e57f641808 100644 --- a/test/integration/goldens/asset/package-info.java +++ b/test/integration/goldens/asset/package-info.java @@ -24,6 +24,6 @@ *

Sample for AssetServiceClient: */ @Generated("by gapic-generator-java") -package com.google.cloud.asset.v1beta1; +package com.google.cloud.asset.v1; import javax.annotation.Generated; diff --git a/test/integration/goldens/redis/CloudRedisClient.java b/test/integration/goldens/redis/CloudRedisClient.java index a9bd0a72a9..75fa4eebdd 100644 --- a/test/integration/goldens/redis/CloudRedisClient.java +++ b/test/integration/goldens/redis/CloudRedisClient.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.cloud.redis.v1; +package com.google.cloud.redis.v1beta1; import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; @@ -28,11 +28,12 @@ import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.PageContext; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.redis.v1.stub.CloudRedisStub; -import com.google.cloud.redis.v1.stub.CloudRedisStubSettings; +import com.google.cloud.redis.v1beta1.stub.CloudRedisStub; +import com.google.cloud.redis.v1beta1.stub.CloudRedisStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; import com.google.longrunning.OperationsClient; +import com.google.protobuf.Any; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -44,7 +45,7 @@ /** * Service Description: Configures and manages Cloud Memorystore for Redis instances * - *

Google Cloud Memorystore for Redis v1 + *

Google Cloud Memorystore for Redis v1beta1 * *

The `redis.googleapis.com` service implements the Google Cloud Memorystore for Redis API and * defines the following resource model for managing Redis instances: @@ -57,7 +58,7 @@ * `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` * * - *

Note that location_id must be referring to a GCP `region`; for example: + *

Note that location_id must be refering to a GCP `region`; for example: * *

    *
  • `projects/redpepper-1290/locations/us-central1/instances/my-redis` @@ -112,6 +113,7 @@ * *

    Please refer to the GitHub repository's samples for more quickstart code snippets. */ +@BetaApi @Generated("by gapic-generator-java") public class CloudRedisClient implements BackgroundResource { private final CloudRedisSettings settings; @@ -365,7 +367,7 @@ public final UnaryCallable getInstanceCallable() { * @param instance Required. A Redis [Instance] resource * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture createInstanceAsync( + public final OperationFuture createInstanceAsync( LocationName parent, String instanceId, Instance instance) { CreateInstanceRequest request = CreateInstanceRequest.newBuilder() @@ -406,7 +408,7 @@ public final OperationFuture createInstanceAsync( * @param instance Required. A Redis [Instance] resource * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture createInstanceAsync( + public final OperationFuture createInstanceAsync( String parent, String instanceId, Instance instance) { CreateInstanceRequest request = CreateInstanceRequest.newBuilder() @@ -435,8 +437,7 @@ public final OperationFuture createInstanceAsync( * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture createInstanceAsync( - CreateInstanceRequest request) { + public final OperationFuture createInstanceAsync(CreateInstanceRequest request) { return createInstanceOperationCallable().futureCall(request); } @@ -457,7 +458,7 @@ public final OperationFuture createInstanceAsync( * *

    Sample code: */ - public final OperationCallable + public final OperationCallable createInstanceOperationCallable() { return stub.createInstanceOperationCallable(); } @@ -493,12 +494,12 @@ public final UnaryCallable createInstanceCalla * * @param updateMask Required. Mask of fields to update. At least one path must be supplied in * this field. The elements of the repeated paths field may only include these fields from - * [Instance][google.cloud.redis.v1.Instance]: + * [Instance][google.cloud.redis.v1beta1.Instance]: *

    * `displayName` * `labels` * `memorySizeGb` * `redisConfig` * @param instance Required. Update description. Only fields specified in update_mask are updated. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture updateInstanceAsync( + public final OperationFuture updateInstanceAsync( FieldMask updateMask, Instance instance) { UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder().setUpdateMask(updateMask).setInstance(instance).build(); @@ -516,8 +517,7 @@ public final OperationFuture updateInstanceAsync( * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture updateInstanceAsync( - UpdateInstanceRequest request) { + public final OperationFuture updateInstanceAsync(UpdateInstanceRequest request) { return updateInstanceOperationCallable().futureCall(request); } @@ -531,7 +531,7 @@ public final OperationFuture updateInstanceAsync( * *

    Sample code: */ - public final OperationCallable + public final OperationCallable updateInstanceOperationCallable() { return stub.updateInstanceOperationCallable(); } @@ -560,7 +560,7 @@ public final UnaryCallable updateInstanceCalla * @param redisVersion Required. Specifies the target version of Redis software to upgrade to. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture upgradeInstanceAsync( + public final OperationFuture upgradeInstanceAsync( InstanceName name, String redisVersion) { UpgradeInstanceRequest request = UpgradeInstanceRequest.newBuilder() @@ -580,7 +580,7 @@ public final OperationFuture upgradeInstanceAsync( * @param redisVersion Required. Specifies the target version of Redis software to upgrade to. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture upgradeInstanceAsync( + public final OperationFuture upgradeInstanceAsync( String name, String redisVersion) { UpgradeInstanceRequest request = UpgradeInstanceRequest.newBuilder().setName(name).setRedisVersion(redisVersion).build(); @@ -594,8 +594,7 @@ public final OperationFuture upgradeInstanceAsync( * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture upgradeInstanceAsync( - UpgradeInstanceRequest request) { + public final OperationFuture upgradeInstanceAsync(UpgradeInstanceRequest request) { return upgradeInstanceOperationCallable().futureCall(request); } @@ -605,7 +604,7 @@ public final OperationFuture upgradeInstanceAsync( * *

    Sample code: */ - public final OperationCallable + public final OperationCallable upgradeInstanceOperationCallable() { return stub.upgradeInstanceOperationCallable(); } @@ -636,7 +635,7 @@ public final UnaryCallable upgradeInstanceCal * @param inputConfig Required. Specify data to be imported. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture importInstanceAsync( + public final OperationFuture importInstanceAsync( String name, InputConfig inputConfig) { ImportInstanceRequest request = ImportInstanceRequest.newBuilder().setName(name).setInputConfig(inputConfig).build(); @@ -656,8 +655,7 @@ public final OperationFuture importInstanceAsync( * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture importInstanceAsync( - ImportInstanceRequest request) { + public final OperationFuture importInstanceAsync(ImportInstanceRequest request) { return importInstanceOperationCallable().futureCall(request); } @@ -673,7 +671,7 @@ public final OperationFuture importInstanceAsync( * *

    Sample code: */ - public final OperationCallable + public final OperationCallable importInstanceOperationCallable() { return stub.importInstanceOperationCallable(); } @@ -709,7 +707,7 @@ public final UnaryCallable importInstanceCalla * @param outputConfig Required. Specify data to be exported. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture exportInstanceAsync( + public final OperationFuture exportInstanceAsync( String name, OutputConfig outputConfig) { ExportInstanceRequest request = ExportInstanceRequest.newBuilder().setName(name).setOutputConfig(outputConfig).build(); @@ -728,8 +726,7 @@ public final OperationFuture exportInstanceAsync( * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture exportInstanceAsync( - ExportInstanceRequest request) { + public final OperationFuture exportInstanceAsync(ExportInstanceRequest request) { return exportInstanceOperationCallable().futureCall(request); } @@ -744,7 +741,7 @@ public final OperationFuture exportInstanceAsync( * *

    Sample code: */ - public final OperationCallable + public final OperationCallable exportInstanceOperationCallable() { return stub.exportInstanceOperationCallable(); } @@ -776,7 +773,7 @@ public final UnaryCallable exportInstanceCalla * If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture failoverInstanceAsync( + public final OperationFuture failoverInstanceAsync( InstanceName name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode) { FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder() @@ -798,7 +795,7 @@ public final OperationFuture failoverInstanceAsync( * If it's unspecified, data protection mode will be LIMITED_DATA_LOSS by default. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture failoverInstanceAsync( + public final OperationFuture failoverInstanceAsync( String name, FailoverInstanceRequest.DataProtectionMode dataProtectionMode) { FailoverInstanceRequest request = FailoverInstanceRequest.newBuilder() @@ -816,7 +813,7 @@ public final OperationFuture failoverInstanceAsync( * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture failoverInstanceAsync( + public final OperationFuture failoverInstanceAsync( FailoverInstanceRequest request) { return failoverInstanceOperationCallable().futureCall(request); } @@ -828,7 +825,7 @@ public final OperationFuture failoverInstanceAsync( * *

    Sample code: */ - public final OperationCallable + public final OperationCallable failoverInstanceOperationCallable() { return stub.failoverInstanceOperationCallable(); } @@ -853,7 +850,7 @@ public final UnaryCallable failoverInstanceC * refers to a GCP region. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture deleteInstanceAsync(InstanceName name) { + public final OperationFuture deleteInstanceAsync(InstanceName name) { DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder().setName(name == null ? null : name.toString()).build(); return deleteInstanceAsync(request); @@ -868,7 +865,7 @@ public final OperationFuture deleteInstanceAsync(Insta * refers to a GCP region. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture deleteInstanceAsync(String name) { + public final OperationFuture deleteInstanceAsync(String name) { DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder().setName(name).build(); return deleteInstanceAsync(request); } @@ -880,8 +877,7 @@ public final OperationFuture deleteInstanceAsync(Strin * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ - public final OperationFuture deleteInstanceAsync( - DeleteInstanceRequest request) { + public final OperationFuture deleteInstanceAsync(DeleteInstanceRequest request) { return deleteInstanceOperationCallable().futureCall(request); } @@ -891,7 +887,7 @@ public final OperationFuture deleteInstanceAsync( * *

    Sample code: */ - public final OperationCallable + public final OperationCallable deleteInstanceOperationCallable() { return stub.deleteInstanceOperationCallable(); } diff --git a/test/integration/goldens/redis/CloudRedisClientTest.java b/test/integration/goldens/redis/CloudRedisClientTest.java index 27908462f4..01190587e4 100644 --- a/test/integration/goldens/redis/CloudRedisClientTest.java +++ b/test/integration/goldens/redis/CloudRedisClientTest.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.google.cloud.redis.v1; +package com.google.cloud.redis.v1beta1; -import static com.google.cloud.redis.v1.CloudRedisClient.ListInstancesPagedResponse; +import static com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.grpc.GaxGrpcProperties; diff --git a/test/integration/goldens/redis/CloudRedisSettings.java b/test/integration/goldens/redis/CloudRedisSettings.java index f13b069810..92e316bff4 100644 --- a/test/integration/goldens/redis/CloudRedisSettings.java +++ b/test/integration/goldens/redis/CloudRedisSettings.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.google.cloud.redis.v1; +package com.google.cloud.redis.v1beta1; -import static com.google.cloud.redis.v1.CloudRedisClient.ListInstancesPagedResponse; +import static com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; @@ -31,8 +31,9 @@ import com.google.api.gax.rpc.StubSettings; import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; -import com.google.cloud.redis.v1.stub.CloudRedisStubSettings; +import com.google.cloud.redis.v1beta1.stub.CloudRedisStubSettings; import com.google.longrunning.Operation; +import com.google.protobuf.Any; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -69,6 +70,7 @@ * CloudRedisSettings cloudRedisSettings = cloudRedisSettingsBuilder.build(); * } */ +@BetaApi @Generated("by gapic-generator-java") public class CloudRedisSettings extends ClientSettings { @@ -89,7 +91,7 @@ public UnaryCallSettings createInstanceSetting } /** Returns the object with the settings used for calls to createInstance. */ - public OperationCallSettings + public OperationCallSettings createInstanceOperationSettings() { return ((CloudRedisStubSettings) getStubSettings()).createInstanceOperationSettings(); } @@ -100,7 +102,7 @@ public UnaryCallSettings updateInstanceSetting } /** Returns the object with the settings used for calls to updateInstance. */ - public OperationCallSettings + public OperationCallSettings updateInstanceOperationSettings() { return ((CloudRedisStubSettings) getStubSettings()).updateInstanceOperationSettings(); } @@ -111,7 +113,7 @@ public UnaryCallSettings upgradeInstanceSetti } /** Returns the object with the settings used for calls to upgradeInstance. */ - public OperationCallSettings + public OperationCallSettings upgradeInstanceOperationSettings() { return ((CloudRedisStubSettings) getStubSettings()).upgradeInstanceOperationSettings(); } @@ -122,7 +124,7 @@ public UnaryCallSettings importInstanceSetting } /** Returns the object with the settings used for calls to importInstance. */ - public OperationCallSettings + public OperationCallSettings importInstanceOperationSettings() { return ((CloudRedisStubSettings) getStubSettings()).importInstanceOperationSettings(); } @@ -133,7 +135,7 @@ public UnaryCallSettings exportInstanceSetting } /** Returns the object with the settings used for calls to exportInstance. */ - public OperationCallSettings + public OperationCallSettings exportInstanceOperationSettings() { return ((CloudRedisStubSettings) getStubSettings()).exportInstanceOperationSettings(); } @@ -144,7 +146,7 @@ public UnaryCallSettings failoverInstanceSet } /** Returns the object with the settings used for calls to failoverInstance. */ - public OperationCallSettings + public OperationCallSettings failoverInstanceOperationSettings() { return ((CloudRedisStubSettings) getStubSettings()).failoverInstanceOperationSettings(); } @@ -155,7 +157,7 @@ public UnaryCallSettings deleteInstanceSetting } /** Returns the object with the settings used for calls to deleteInstance. */ - public OperationCallSettings + public OperationCallSettings deleteInstanceOperationSettings() { return ((CloudRedisStubSettings) getStubSettings()).deleteInstanceOperationSettings(); } @@ -275,7 +277,7 @@ public UnaryCallSettings.Builder createInstanc } /** Returns the builder for the settings used for calls to createInstance. */ - public OperationCallSettings.Builder + public OperationCallSettings.Builder createInstanceOperationSettings() { return getStubSettingsBuilder().createInstanceOperationSettings(); } @@ -286,7 +288,7 @@ public UnaryCallSettings.Builder updateInstanc } /** Returns the builder for the settings used for calls to updateInstance. */ - public OperationCallSettings.Builder + public OperationCallSettings.Builder updateInstanceOperationSettings() { return getStubSettingsBuilder().updateInstanceOperationSettings(); } @@ -297,7 +299,7 @@ public UnaryCallSettings.Builder upgradeInsta } /** Returns the builder for the settings used for calls to upgradeInstance. */ - public OperationCallSettings.Builder + public OperationCallSettings.Builder upgradeInstanceOperationSettings() { return getStubSettingsBuilder().upgradeInstanceOperationSettings(); } @@ -308,7 +310,7 @@ public UnaryCallSettings.Builder importInstanc } /** Returns the builder for the settings used for calls to importInstance. */ - public OperationCallSettings.Builder + public OperationCallSettings.Builder importInstanceOperationSettings() { return getStubSettingsBuilder().importInstanceOperationSettings(); } @@ -319,7 +321,7 @@ public UnaryCallSettings.Builder exportInstanc } /** Returns the builder for the settings used for calls to exportInstance. */ - public OperationCallSettings.Builder + public OperationCallSettings.Builder exportInstanceOperationSettings() { return getStubSettingsBuilder().exportInstanceOperationSettings(); } @@ -331,7 +333,7 @@ public UnaryCallSettings.Builder exportInstanc } /** Returns the builder for the settings used for calls to failoverInstance. */ - public OperationCallSettings.Builder + public OperationCallSettings.Builder failoverInstanceOperationSettings() { return getStubSettingsBuilder().failoverInstanceOperationSettings(); } @@ -342,7 +344,7 @@ public UnaryCallSettings.Builder deleteInstanc } /** Returns the builder for the settings used for calls to deleteInstance. */ - public OperationCallSettings.Builder + public OperationCallSettings.Builder deleteInstanceOperationSettings() { return getStubSettingsBuilder().deleteInstanceOperationSettings(); } diff --git a/test/integration/goldens/redis/CloudRedisStub.java b/test/integration/goldens/redis/CloudRedisStub.java index 86a7d63e4e..a3ecc3945d 100644 --- a/test/integration/goldens/redis/CloudRedisStub.java +++ b/test/integration/goldens/redis/CloudRedisStub.java @@ -14,27 +14,28 @@ * limitations under the License. */ -package com.google.cloud.redis.v1.stub; +package com.google.cloud.redis.v1beta1.stub; -import static com.google.cloud.redis.v1.CloudRedisClient.ListInstancesPagedResponse; +import static com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.redis.v1.CreateInstanceRequest; -import com.google.cloud.redis.v1.DeleteInstanceRequest; -import com.google.cloud.redis.v1.ExportInstanceRequest; -import com.google.cloud.redis.v1.FailoverInstanceRequest; -import com.google.cloud.redis.v1.GetInstanceRequest; -import com.google.cloud.redis.v1.ImportInstanceRequest; -import com.google.cloud.redis.v1.Instance; -import com.google.cloud.redis.v1.ListInstancesRequest; -import com.google.cloud.redis.v1.ListInstancesResponse; -import com.google.cloud.redis.v1.OperationMetadata; -import com.google.cloud.redis.v1.UpdateInstanceRequest; -import com.google.cloud.redis.v1.UpgradeInstanceRequest; +import com.google.cloud.redis.v1beta1.CreateInstanceRequest; +import com.google.cloud.redis.v1beta1.DeleteInstanceRequest; +import com.google.cloud.redis.v1beta1.ExportInstanceRequest; +import com.google.cloud.redis.v1beta1.FailoverInstanceRequest; +import com.google.cloud.redis.v1beta1.GetInstanceRequest; +import com.google.cloud.redis.v1beta1.ImportInstanceRequest; +import com.google.cloud.redis.v1beta1.Instance; +import com.google.cloud.redis.v1beta1.ListInstancesRequest; +import com.google.cloud.redis.v1beta1.ListInstancesResponse; +import com.google.cloud.redis.v1beta1.UpdateInstanceRequest; +import com.google.cloud.redis.v1beta1.UpgradeInstanceRequest; import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; +import com.google.protobuf.Any; import com.google.protobuf.Empty; import javax.annotation.Generated; @@ -44,6 +45,7 @@ * *

    This class is for advanced usage and reflects the underlying API directly. */ +@BetaApi @Generated("by gapic-generator-java") public abstract class CloudRedisStub implements BackgroundResource { @@ -64,8 +66,7 @@ public UnaryCallable getInstanceCallable() { throw new UnsupportedOperationException("Not implemented: getInstanceCallable()"); } - public OperationCallable - createInstanceOperationCallable() { + public OperationCallable createInstanceOperationCallable() { throw new UnsupportedOperationException("Not implemented: createInstanceOperationCallable()"); } @@ -73,8 +74,7 @@ public UnaryCallable createInstanceCallable() throw new UnsupportedOperationException("Not implemented: createInstanceCallable()"); } - public OperationCallable - updateInstanceOperationCallable() { + public OperationCallable updateInstanceOperationCallable() { throw new UnsupportedOperationException("Not implemented: updateInstanceOperationCallable()"); } @@ -82,7 +82,7 @@ public UnaryCallable updateInstanceCallable() throw new UnsupportedOperationException("Not implemented: updateInstanceCallable()"); } - public OperationCallable + public OperationCallable upgradeInstanceOperationCallable() { throw new UnsupportedOperationException("Not implemented: upgradeInstanceOperationCallable()"); } @@ -91,8 +91,7 @@ public UnaryCallable upgradeInstanceCallable( throw new UnsupportedOperationException("Not implemented: upgradeInstanceCallable()"); } - public OperationCallable - importInstanceOperationCallable() { + public OperationCallable importInstanceOperationCallable() { throw new UnsupportedOperationException("Not implemented: importInstanceOperationCallable()"); } @@ -100,8 +99,7 @@ public UnaryCallable importInstanceCallable() throw new UnsupportedOperationException("Not implemented: importInstanceCallable()"); } - public OperationCallable - exportInstanceOperationCallable() { + public OperationCallable exportInstanceOperationCallable() { throw new UnsupportedOperationException("Not implemented: exportInstanceOperationCallable()"); } @@ -109,7 +107,7 @@ public UnaryCallable exportInstanceCallable() throw new UnsupportedOperationException("Not implemented: exportInstanceCallable()"); } - public OperationCallable + public OperationCallable failoverInstanceOperationCallable() { throw new UnsupportedOperationException("Not implemented: failoverInstanceOperationCallable()"); } @@ -118,8 +116,7 @@ public UnaryCallable failoverInstanceCallabl throw new UnsupportedOperationException("Not implemented: failoverInstanceCallable()"); } - public OperationCallable - deleteInstanceOperationCallable() { + public OperationCallable deleteInstanceOperationCallable() { throw new UnsupportedOperationException("Not implemented: deleteInstanceOperationCallable()"); } diff --git a/test/integration/goldens/redis/CloudRedisStubSettings.java b/test/integration/goldens/redis/CloudRedisStubSettings.java index 7588be3456..f911e92382 100644 --- a/test/integration/goldens/redis/CloudRedisStubSettings.java +++ b/test/integration/goldens/redis/CloudRedisStubSettings.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.google.cloud.redis.v1.stub; +package com.google.cloud.redis.v1beta1.stub; -import static com.google.cloud.redis.v1.CloudRedisClient.ListInstancesPagedResponse; +import static com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse; import com.google.api.core.ApiFunction; import com.google.api.core.ApiFuture; @@ -44,23 +44,23 @@ import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.redis.v1.CreateInstanceRequest; -import com.google.cloud.redis.v1.DeleteInstanceRequest; -import com.google.cloud.redis.v1.ExportInstanceRequest; -import com.google.cloud.redis.v1.FailoverInstanceRequest; -import com.google.cloud.redis.v1.GetInstanceRequest; -import com.google.cloud.redis.v1.ImportInstanceRequest; -import com.google.cloud.redis.v1.Instance; -import com.google.cloud.redis.v1.ListInstancesRequest; -import com.google.cloud.redis.v1.ListInstancesResponse; -import com.google.cloud.redis.v1.OperationMetadata; -import com.google.cloud.redis.v1.UpdateInstanceRequest; -import com.google.cloud.redis.v1.UpgradeInstanceRequest; +import com.google.cloud.redis.v1beta1.CreateInstanceRequest; +import com.google.cloud.redis.v1beta1.DeleteInstanceRequest; +import com.google.cloud.redis.v1beta1.ExportInstanceRequest; +import com.google.cloud.redis.v1beta1.FailoverInstanceRequest; +import com.google.cloud.redis.v1beta1.GetInstanceRequest; +import com.google.cloud.redis.v1beta1.ImportInstanceRequest; +import com.google.cloud.redis.v1beta1.Instance; +import com.google.cloud.redis.v1beta1.ListInstancesRequest; +import com.google.cloud.redis.v1beta1.ListInstancesResponse; +import com.google.cloud.redis.v1beta1.UpdateInstanceRequest; +import com.google.cloud.redis.v1beta1.UpgradeInstanceRequest; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.longrunning.Operation; +import com.google.protobuf.Any; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -98,6 +98,7 @@ * CloudRedisStubSettings cloudRedisSettings = cloudRedisSettingsBuilder.build(); * } */ +@BetaApi @Generated("by gapic-generator-java") public class CloudRedisStubSettings extends StubSettings { /** The default scopes of the service. */ @@ -109,25 +110,25 @@ public class CloudRedisStubSettings extends StubSettings listInstancesSettings; private final UnaryCallSettings getInstanceSettings; private final UnaryCallSettings createInstanceSettings; - private final OperationCallSettings + private final OperationCallSettings createInstanceOperationSettings; private final UnaryCallSettings updateInstanceSettings; - private final OperationCallSettings + private final OperationCallSettings updateInstanceOperationSettings; private final UnaryCallSettings upgradeInstanceSettings; - private final OperationCallSettings + private final OperationCallSettings upgradeInstanceOperationSettings; private final UnaryCallSettings importInstanceSettings; - private final OperationCallSettings + private final OperationCallSettings importInstanceOperationSettings; private final UnaryCallSettings exportInstanceSettings; - private final OperationCallSettings + private final OperationCallSettings exportInstanceOperationSettings; private final UnaryCallSettings failoverInstanceSettings; - private final OperationCallSettings + private final OperationCallSettings failoverInstanceOperationSettings; private final UnaryCallSettings deleteInstanceSettings; - private final OperationCallSettings + private final OperationCallSettings deleteInstanceOperationSettings; private static final PagedListDescriptor @@ -200,7 +201,7 @@ public UnaryCallSettings createInstanceSetting } /** Returns the object with the settings used for calls to createInstance. */ - public OperationCallSettings + public OperationCallSettings createInstanceOperationSettings() { return createInstanceOperationSettings; } @@ -211,7 +212,7 @@ public UnaryCallSettings updateInstanceSetting } /** Returns the object with the settings used for calls to updateInstance. */ - public OperationCallSettings + public OperationCallSettings updateInstanceOperationSettings() { return updateInstanceOperationSettings; } @@ -222,7 +223,7 @@ public UnaryCallSettings upgradeInstanceSetti } /** Returns the object with the settings used for calls to upgradeInstance. */ - public OperationCallSettings + public OperationCallSettings upgradeInstanceOperationSettings() { return upgradeInstanceOperationSettings; } @@ -233,7 +234,7 @@ public UnaryCallSettings importInstanceSetting } /** Returns the object with the settings used for calls to importInstance. */ - public OperationCallSettings + public OperationCallSettings importInstanceOperationSettings() { return importInstanceOperationSettings; } @@ -244,7 +245,7 @@ public UnaryCallSettings exportInstanceSetting } /** Returns the object with the settings used for calls to exportInstance. */ - public OperationCallSettings + public OperationCallSettings exportInstanceOperationSettings() { return exportInstanceOperationSettings; } @@ -255,7 +256,7 @@ public UnaryCallSettings failoverInstanceSet } /** Returns the object with the settings used for calls to failoverInstance. */ - public OperationCallSettings + public OperationCallSettings failoverInstanceOperationSettings() { return failoverInstanceOperationSettings; } @@ -266,7 +267,7 @@ public UnaryCallSettings deleteInstanceSetting } /** Returns the object with the settings used for calls to deleteInstance. */ - public OperationCallSettings + public OperationCallSettings deleteInstanceOperationSettings() { return deleteInstanceOperationSettings; } @@ -367,32 +368,31 @@ public static class Builder extends StubSettings.Builder getInstanceSettings; private final UnaryCallSettings.Builder createInstanceSettings; - private final OperationCallSettings.Builder + private final OperationCallSettings.Builder createInstanceOperationSettings; private final UnaryCallSettings.Builder updateInstanceSettings; - private final OperationCallSettings.Builder + private final OperationCallSettings.Builder updateInstanceOperationSettings; private final UnaryCallSettings.Builder upgradeInstanceSettings; - private final OperationCallSettings.Builder + private final OperationCallSettings.Builder upgradeInstanceOperationSettings; private final UnaryCallSettings.Builder importInstanceSettings; - private final OperationCallSettings.Builder + private final OperationCallSettings.Builder importInstanceOperationSettings; private final UnaryCallSettings.Builder exportInstanceSettings; - private final OperationCallSettings.Builder + private final OperationCallSettings.Builder exportInstanceOperationSettings; private final UnaryCallSettings.Builder failoverInstanceSettings; - private final OperationCallSettings.Builder< - FailoverInstanceRequest, Instance, OperationMetadata> + private final OperationCallSettings.Builder failoverInstanceOperationSettings; private final UnaryCallSettings.Builder deleteInstanceSettings; - private final OperationCallSettings.Builder + private final OperationCallSettings.Builder deleteInstanceOperationSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -559,8 +559,7 @@ private static Builder initDefaults(Builder builder) { .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Instance.class)) - .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Any.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() @@ -570,7 +569,7 @@ private static Builder initDefaults(Builder builder) { .setInitialRpcTimeout(Duration.ZERO) .setRpcTimeoutMultiplier(1.0) .setMaxRpcTimeout(Duration.ZERO) - .setTotalTimeout(Duration.ofMillis(7200000L)) + .setTotalTimeout(Duration.ofMillis(1200000L)) .build())); builder @@ -583,8 +582,7 @@ private static Builder initDefaults(Builder builder) { .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Instance.class)) - .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Any.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() @@ -607,8 +605,7 @@ private static Builder initDefaults(Builder builder) { .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Instance.class)) - .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Any.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() @@ -631,8 +628,7 @@ private static Builder initDefaults(Builder builder) { .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Instance.class)) - .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Any.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() @@ -655,8 +651,7 @@ private static Builder initDefaults(Builder builder) { .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Instance.class)) - .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Any.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() @@ -679,8 +674,7 @@ private static Builder initDefaults(Builder builder) { .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Instance.class)) - .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Any.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() @@ -703,8 +697,7 @@ private static Builder initDefaults(Builder builder) { .build()) .setResponseTransformer( ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) - .setMetadataTransformer( - ProtoOperationTransformers.MetadataTransformer.create(OperationMetadata.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(Any.class)) .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() @@ -756,7 +749,7 @@ public UnaryCallSettings.Builder createInstanc /** Returns the builder for the settings used for calls to createInstance. */ @BetaApi( "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder + public OperationCallSettings.Builder createInstanceOperationSettings() { return createInstanceOperationSettings; } @@ -769,7 +762,7 @@ public UnaryCallSettings.Builder updateInstanc /** Returns the builder for the settings used for calls to updateInstance. */ @BetaApi( "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder + public OperationCallSettings.Builder updateInstanceOperationSettings() { return updateInstanceOperationSettings; } @@ -782,7 +775,7 @@ public UnaryCallSettings.Builder upgradeInsta /** Returns the builder for the settings used for calls to upgradeInstance. */ @BetaApi( "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder + public OperationCallSettings.Builder upgradeInstanceOperationSettings() { return upgradeInstanceOperationSettings; } @@ -795,7 +788,7 @@ public UnaryCallSettings.Builder importInstanc /** Returns the builder for the settings used for calls to importInstance. */ @BetaApi( "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder + public OperationCallSettings.Builder importInstanceOperationSettings() { return importInstanceOperationSettings; } @@ -808,7 +801,7 @@ public UnaryCallSettings.Builder exportInstanc /** Returns the builder for the settings used for calls to exportInstance. */ @BetaApi( "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder + public OperationCallSettings.Builder exportInstanceOperationSettings() { return exportInstanceOperationSettings; } @@ -822,7 +815,7 @@ public UnaryCallSettings.Builder exportInstanc /** Returns the builder for the settings used for calls to failoverInstance. */ @BetaApi( "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder + public OperationCallSettings.Builder failoverInstanceOperationSettings() { return failoverInstanceOperationSettings; } @@ -835,7 +828,7 @@ public UnaryCallSettings.Builder deleteInstanc /** Returns the builder for the settings used for calls to deleteInstance. */ @BetaApi( "The surface for use by generated code is not stable yet and may change in the future.") - public OperationCallSettings.Builder + public OperationCallSettings.Builder deleteInstanceOperationSettings() { return deleteInstanceOperationSettings; } diff --git a/test/integration/goldens/redis/GrpcCloudRedisCallableFactory.java b/test/integration/goldens/redis/GrpcCloudRedisCallableFactory.java index f827378089..411e4955de 100644 --- a/test/integration/goldens/redis/GrpcCloudRedisCallableFactory.java +++ b/test/integration/goldens/redis/GrpcCloudRedisCallableFactory.java @@ -14,8 +14,9 @@ * limitations under the License. */ -package com.google.cloud.redis.v1.stub; +package com.google.cloud.redis.v1beta1.stub; +import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -41,6 +42,7 @@ * *

    This class is for advanced usage. */ +@BetaApi @Generated("by gapic-generator-java") public class GrpcCloudRedisCallableFactory implements GrpcStubCallableFactory { diff --git a/test/integration/goldens/redis/GrpcCloudRedisStub.java b/test/integration/goldens/redis/GrpcCloudRedisStub.java index 474cc567de..416417d996 100644 --- a/test/integration/goldens/redis/GrpcCloudRedisStub.java +++ b/test/integration/goldens/redis/GrpcCloudRedisStub.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package com.google.cloud.redis.v1.stub; +package com.google.cloud.redis.v1beta1.stub; -import static com.google.cloud.redis.v1.CloudRedisClient.ListInstancesPagedResponse; +import static com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -26,21 +27,21 @@ import com.google.api.gax.rpc.OperationCallable; import com.google.api.gax.rpc.RequestParamsExtractor; import com.google.api.gax.rpc.UnaryCallable; -import com.google.cloud.redis.v1.CreateInstanceRequest; -import com.google.cloud.redis.v1.DeleteInstanceRequest; -import com.google.cloud.redis.v1.ExportInstanceRequest; -import com.google.cloud.redis.v1.FailoverInstanceRequest; -import com.google.cloud.redis.v1.GetInstanceRequest; -import com.google.cloud.redis.v1.ImportInstanceRequest; -import com.google.cloud.redis.v1.Instance; -import com.google.cloud.redis.v1.ListInstancesRequest; -import com.google.cloud.redis.v1.ListInstancesResponse; -import com.google.cloud.redis.v1.OperationMetadata; -import com.google.cloud.redis.v1.UpdateInstanceRequest; -import com.google.cloud.redis.v1.UpgradeInstanceRequest; +import com.google.cloud.redis.v1beta1.CreateInstanceRequest; +import com.google.cloud.redis.v1beta1.DeleteInstanceRequest; +import com.google.cloud.redis.v1beta1.ExportInstanceRequest; +import com.google.cloud.redis.v1beta1.FailoverInstanceRequest; +import com.google.cloud.redis.v1beta1.GetInstanceRequest; +import com.google.cloud.redis.v1beta1.ImportInstanceRequest; +import com.google.cloud.redis.v1beta1.Instance; +import com.google.cloud.redis.v1beta1.ListInstancesRequest; +import com.google.cloud.redis.v1beta1.ListInstancesResponse; +import com.google.cloud.redis.v1beta1.UpdateInstanceRequest; +import com.google.cloud.redis.v1beta1.UpgradeInstanceRequest; import com.google.common.collect.ImmutableMap; import com.google.longrunning.Operation; import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Any; import com.google.protobuf.Empty; import io.grpc.MethodDescriptor; import io.grpc.protobuf.ProtoUtils; @@ -55,13 +56,14 @@ * *

    This class is for advanced usage and reflects the underlying API directly. */ +@BetaApi @Generated("by gapic-generator-java") public class GrpcCloudRedisStub extends CloudRedisStub { private static final MethodDescriptor listInstancesMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/ListInstances") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/ListInstances") .setRequestMarshaller( ProtoUtils.marshaller(ListInstancesRequest.getDefaultInstance())) .setResponseMarshaller( @@ -71,7 +73,7 @@ public class GrpcCloudRedisStub extends CloudRedisStub { private static final MethodDescriptor getInstanceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/GetInstance") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/GetInstance") .setRequestMarshaller(ProtoUtils.marshaller(GetInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Instance.getDefaultInstance())) .build(); @@ -80,7 +82,7 @@ public class GrpcCloudRedisStub extends CloudRedisStub { createInstanceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/CreateInstance") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/CreateInstance") .setRequestMarshaller( ProtoUtils.marshaller(CreateInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) @@ -90,7 +92,7 @@ public class GrpcCloudRedisStub extends CloudRedisStub { updateInstanceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/UpdateInstance") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/UpdateInstance") .setRequestMarshaller( ProtoUtils.marshaller(UpdateInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) @@ -100,7 +102,7 @@ public class GrpcCloudRedisStub extends CloudRedisStub { upgradeInstanceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/UpgradeInstance") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/UpgradeInstance") .setRequestMarshaller( ProtoUtils.marshaller(UpgradeInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) @@ -110,7 +112,7 @@ public class GrpcCloudRedisStub extends CloudRedisStub { importInstanceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/ImportInstance") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/ImportInstance") .setRequestMarshaller( ProtoUtils.marshaller(ImportInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) @@ -120,7 +122,7 @@ public class GrpcCloudRedisStub extends CloudRedisStub { exportInstanceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/ExportInstance") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/ExportInstance") .setRequestMarshaller( ProtoUtils.marshaller(ExportInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) @@ -130,7 +132,7 @@ public class GrpcCloudRedisStub extends CloudRedisStub { failoverInstanceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/FailoverInstance") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/FailoverInstance") .setRequestMarshaller( ProtoUtils.marshaller(FailoverInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) @@ -140,7 +142,7 @@ public class GrpcCloudRedisStub extends CloudRedisStub { deleteInstanceMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.redis.v1.CloudRedis/DeleteInstance") + .setFullMethodName("google.cloud.redis.v1beta1.CloudRedis/DeleteInstance") .setRequestMarshaller( ProtoUtils.marshaller(DeleteInstanceRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) @@ -151,25 +153,25 @@ public class GrpcCloudRedisStub extends CloudRedisStub { listInstancesPagedCallable; private final UnaryCallable getInstanceCallable; private final UnaryCallable createInstanceCallable; - private final OperationCallable + private final OperationCallable createInstanceOperationCallable; private final UnaryCallable updateInstanceCallable; - private final OperationCallable + private final OperationCallable updateInstanceOperationCallable; private final UnaryCallable upgradeInstanceCallable; - private final OperationCallable + private final OperationCallable upgradeInstanceOperationCallable; private final UnaryCallable importInstanceCallable; - private final OperationCallable + private final OperationCallable importInstanceOperationCallable; private final UnaryCallable exportInstanceCallable; - private final OperationCallable + private final OperationCallable exportInstanceOperationCallable; private final UnaryCallable failoverInstanceCallable; - private final OperationCallable + private final OperationCallable failoverInstanceOperationCallable; private final UnaryCallable deleteInstanceCallable; - private final OperationCallable + private final OperationCallable deleteInstanceOperationCallable; private final BackgroundResource backgroundResources; @@ -430,8 +432,7 @@ public UnaryCallable createInstanceCallable() return createInstanceCallable; } - public OperationCallable - createInstanceOperationCallable() { + public OperationCallable createInstanceOperationCallable() { return createInstanceOperationCallable; } @@ -439,8 +440,7 @@ public UnaryCallable updateInstanceCallable() return updateInstanceCallable; } - public OperationCallable - updateInstanceOperationCallable() { + public OperationCallable updateInstanceOperationCallable() { return updateInstanceOperationCallable; } @@ -448,7 +448,7 @@ public UnaryCallable upgradeInstanceCallable( return upgradeInstanceCallable; } - public OperationCallable + public OperationCallable upgradeInstanceOperationCallable() { return upgradeInstanceOperationCallable; } @@ -457,8 +457,7 @@ public UnaryCallable importInstanceCallable() return importInstanceCallable; } - public OperationCallable - importInstanceOperationCallable() { + public OperationCallable importInstanceOperationCallable() { return importInstanceOperationCallable; } @@ -466,8 +465,7 @@ public UnaryCallable exportInstanceCallable() return exportInstanceCallable; } - public OperationCallable - exportInstanceOperationCallable() { + public OperationCallable exportInstanceOperationCallable() { return exportInstanceOperationCallable; } @@ -475,7 +473,7 @@ public UnaryCallable failoverInstanceCallabl return failoverInstanceCallable; } - public OperationCallable + public OperationCallable failoverInstanceOperationCallable() { return failoverInstanceOperationCallable; } @@ -484,8 +482,7 @@ public UnaryCallable deleteInstanceCallable() return deleteInstanceCallable; } - public OperationCallable - deleteInstanceOperationCallable() { + public OperationCallable deleteInstanceOperationCallable() { return deleteInstanceOperationCallable; } diff --git a/test/integration/goldens/redis/InstanceName.java b/test/integration/goldens/redis/InstanceName.java index d3613b41c2..610c994619 100644 --- a/test/integration/goldens/redis/InstanceName.java +++ b/test/integration/goldens/redis/InstanceName.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.cloud.redis.v1; +package com.google.cloud.redis.v1beta1; import com.google.api.pathtemplate.PathTemplate; import com.google.api.resourcenames.ResourceName; diff --git a/test/integration/goldens/redis/LocationName.java b/test/integration/goldens/redis/LocationName.java index 966cb332b5..e4ff950ac5 100644 --- a/test/integration/goldens/redis/LocationName.java +++ b/test/integration/goldens/redis/LocationName.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.cloud.redis.v1; +package com.google.cloud.redis.v1beta1; import com.google.api.pathtemplate.PathTemplate; import com.google.api.resourcenames.ResourceName; diff --git a/test/integration/goldens/redis/MockCloudRedis.java b/test/integration/goldens/redis/MockCloudRedis.java index acbf9c33d0..00b4a0316e 100644 --- a/test/integration/goldens/redis/MockCloudRedis.java +++ b/test/integration/goldens/redis/MockCloudRedis.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.cloud.redis.v1; +package com.google.cloud.redis.v1beta1; import com.google.api.core.BetaApi; import com.google.api.gax.grpc.testing.MockGrpcService; diff --git a/test/integration/goldens/redis/MockCloudRedisImpl.java b/test/integration/goldens/redis/MockCloudRedisImpl.java index 434f9d3f57..953045dea1 100644 --- a/test/integration/goldens/redis/MockCloudRedisImpl.java +++ b/test/integration/goldens/redis/MockCloudRedisImpl.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.google.cloud.redis.v1; +package com.google.cloud.redis.v1beta1; import com.google.api.core.BetaApi; -import com.google.cloud.redis.v1.CloudRedisGrpc.CloudRedisImplBase; +import com.google.cloud.redis.v1beta1.CloudRedisGrpc.CloudRedisImplBase; import com.google.longrunning.Operation; import com.google.protobuf.AbstractMessage; import io.grpc.stub.StreamObserver; diff --git a/test/integration/goldens/redis/package-info.java b/test/integration/goldens/redis/package-info.java index 3ed9ea15f2..34ceb21ccf 100644 --- a/test/integration/goldens/redis/package-info.java +++ b/test/integration/goldens/redis/package-info.java @@ -21,7 +21,7 @@ * *

    Service Description: Configures and manages Cloud Memorystore for Redis instances * - *

    Google Cloud Memorystore for Redis v1 + *

    Google Cloud Memorystore for Redis v1beta1 * *

    The `redis.googleapis.com` service implements the Google Cloud Memorystore for Redis API and * defines the following resource model for managing Redis instances: @@ -34,7 +34,7 @@ * `/projects/{project_id}/locations/{location_id}/instances/{instance_id}` *

* - *

Note that location_id must be referring to a GCP `region`; for example: + *

Note that location_id must be refering to a GCP `region`; for example: * *

    *
  • `projects/redpepper-1290/locations/us-central1/instances/my-redis` @@ -43,6 +43,6 @@ *

    Sample for CloudRedisClient: */ @Generated("by gapic-generator-java") -package com.google.cloud.redis.v1; +package com.google.cloud.redis.v1beta1; import javax.annotation.Generated;