diff --git a/rules_gapic/gapic.bzl b/rules_gapic/gapic.bzl index fb0ccf2fe6..b8edc5ae79 100644 --- a/rules_gapic/gapic.bzl +++ b/rules_gapic/gapic.bzl @@ -40,11 +40,13 @@ def _gapic_srcjar_impl(ctx): _set_args(attr.service_yaml, "--service_yaml=", arguments, inputs) _set_args(attr.package_yaml2, "--package_yaml2=", arguments, inputs) _set_args(attr.grpc_service_config, "--grpc_service_config=", arguments, inputs) + _set_args(attr.transport, "--transport=", arguments) else: _set_args(attr.language, "--language=", arguments) _set_args(attr.src, "--descriptor=", arguments, inputs) _set_args(attr.package, "--package=", arguments) _set_args(attr.grpc_service_config, "--grpc_service_config=", arguments, inputs) + _set_args(attr.transport, "--transport=", arguments) gapic_generator = ctx.executable.gapic_generator ctx.actions.run( @@ -72,6 +74,7 @@ gapic_srcjar = rule( "package": attr.string(mandatory = False), "output_suffix": attr.string(mandatory = False, default = ".srcjar"), "grpc_service_config": attr.label(mandatory = False, allow_single_file = True), + "transport": attr.string(mandatory = False), "gapic_generator": attr.label( default = Label("//:gapic_generator"), executable = True, diff --git a/rules_gapic/java/java_gapic.bzl b/rules_gapic/java/java_gapic.bzl index d157da59a4..9be1645f96 100644 --- a/rules_gapic/java/java_gapic.bzl +++ b/rules_gapic/java/java_gapic.bzl @@ -78,6 +78,7 @@ def java_gapic_srcjar( package = None, service_yaml = None, grpc_service_config = None, + transport = None, **kwargs): raw_srcjar_name = "%s_raw" % name @@ -90,6 +91,7 @@ def java_gapic_srcjar( language = "java", package = package, grpc_service_config = grpc_service_config, + transport = transport, **kwargs ) @@ -132,6 +134,7 @@ def java_gapic_library( package = None, gen_resource_name = True, grpc_service_config = None, + transport = None, deps = [], test_deps = [], **kwargs): @@ -144,6 +147,7 @@ def java_gapic_library( artifact_type = "GAPIC_CODE", package = package, grpc_service_config = grpc_service_config, + transport = transport, **kwargs ) @@ -162,10 +166,7 @@ def java_gapic_library( "@com_google_protobuf//:protobuf_java", "@com_google_api_api_common//jar", "@com_google_api_gax_java//gax:gax", - "@com_google_api_gax_java//gax-grpc:gax_grpc", "@com_google_guava_guava//jar", - "@io_grpc_grpc_java//core:core", - "@io_grpc_grpc_java//protobuf:protobuf", "@com_google_code_findbugs_jsr305//jar", "@org_threeten_threetenbp//jar", "@io_opencensus_opencensus_api//jar", @@ -175,6 +176,17 @@ def java_gapic_library( "@javax_annotation_javax_annotation_api//jar", ] + if transport == "rest": + actual_deps += [ + "@com_google_api_gax_java//gax-httpjson:gax_httpjson", + ] + else: + actual_deps += [ + "@com_google_api_gax_java//gax-grpc:gax_grpc", + "@io_grpc_grpc_java//core:core", + "@io_grpc_grpc_java//protobuf:protobuf", + ] + native.java_library( name = name, srcs = [":%s.srcjar" % srcjar_name], @@ -183,16 +195,24 @@ def java_gapic_library( ) actual_test_deps = test_deps + [ - "@com_google_api_gax_java//gax-grpc:gax_grpc_testlib", "@com_google_api_gax_java//gax:gax_testlib", "@com_google_code_gson_gson//jar", - "@io_grpc_grpc_java//auth:auth", - "@io_grpc_grpc_netty_shaded//jar", - "@io_grpc_grpc_java//stub:stub", - "@io_opencensus_opencensus_contrib_grpc_metrics//jar", "@junit_junit//jar", ] + if transport == "rest": + actual_test_deps += [ + "@com_google_api_gax_java//gax-httpjson:gax_httpjson_testlib", + ] + else: + actual_test_deps += [ + "@com_google_api_gax_java//gax-grpc:gax_grpc_testlib", + "@io_grpc_grpc_java//auth:auth", + "@io_grpc_grpc_netty_shaded//jar", + "@io_grpc_grpc_java//stub:stub", + "@io_opencensus_opencensus_contrib_grpc_metrics//jar", + ] + native.java_library( name = "%s_test" % name, srcs = [":%s-test.srcjar" % srcjar_name], diff --git a/rules_gapic/java/java_gapic_pkg.bzl b/rules_gapic/java/java_gapic_pkg.bzl index 644a4d7779..9336044758 100644 --- a/rules_gapic/java/java_gapic_pkg.bzl +++ b/rules_gapic/java/java_gapic_pkg.bzl @@ -160,6 +160,7 @@ def java_gapic_assembly_gradle_pkg( name, deps, assembly_name = None, + transport = None, **kwargs): package_dir = name if assembly_name: @@ -206,9 +207,14 @@ def java_gapic_assembly_gradle_pkg( grpc_target_dep = ["%s" % grpc_target] if client_deps: + if transport == "rest": + template_label = Label("//rules_gapic/java:resources/gradle/client_disco.gradle.tmpl") + else: + template_label = Label("//rules_gapic/java:resources/gradle/client.gradle.tmpl") + _java_gapic_gradle_pkg( name = client_target, - template_label = Label("//rules_gapic/java:resources/gradle/client.gradle.tmpl"), + template_label = template_label, deps = proto_target_dep + client_deps, test_deps = grpc_target_dep + client_test_deps, **kwargs diff --git a/src/main/java/com/google/api/codegen/GeneratorMain.java b/src/main/java/com/google/api/codegen/GeneratorMain.java index 458a38c832..49ccebde26 100644 --- a/src/main/java/com/google/api/codegen/GeneratorMain.java +++ b/src/main/java/com/google/api/codegen/GeneratorMain.java @@ -149,6 +149,17 @@ public class GeneratorMain { .argName("GRPC-SERVICE-CONFIG") .required(false) .build(); + private static final Option TRANSPORT = + Option.builder() + .longOpt("transport") + .desc( + "List of transports to support. Valid transport names ('grpc' or 'rest') are" + + " separated by '+'. Default is 'grpc'. NOTE: for now, GAPICs support only" + + " the first transport in the list.") + .hasArg() + .argName("TRANSPORT") + .required(false) + .build(); public static void printAvailableCommands() { System.err.println(" Available artifact types:"); @@ -249,6 +260,7 @@ public static void gapicGeneratorMain(ArtifactType artifactType, String[] args) options.addOption(OUTPUT_OPTION); options.addOption(SAMPLE_YAML_NONREQUIRED_OPTION); options.addOption(GRPC_SERVICE_CONFIG_OPTION); + options.addOption(TRANSPORT); Option enabledArtifactsOption = Option.builder() .longOpt("enabled_artifacts") @@ -299,6 +311,9 @@ public static void gapicGeneratorMain(ArtifactType artifactType, String[] args) checkFile(toolOptions.get(ToolOptions.DESCRIPTOR_SET)); + if (cl.getOptionValue(TRANSPORT.getLongOpt()) != null) { + toolOptions.set(GapicGeneratorApp.TRANSPORT, cl.getOptionValue(TRANSPORT.getLongOpt())); + } if (cl.getOptionValues(SERVICE_YAML_NONREQUIRED_OPTION.getLongOpt()) != null) { toolOptions.set( ToolOptions.CONFIG_FILES, @@ -346,6 +361,7 @@ public static ToolOptions createCodeGeneratorOptionsFromProtoc(String[] args) options.addOption(DESCRIPTOR_SET_OPTION); options.addOption(LANGUAGE_OPTION); options.addOption(TARGET_API_PROTO_PACKAGE); + options.addOption(TRANSPORT); CommandLine cl = (new DefaultParser()).parse(options, args); diff --git a/src/main/java/com/google/api/codegen/config/GapicInterfaceContext.java b/src/main/java/com/google/api/codegen/config/GapicInterfaceContext.java index 9f5eaf39f8..234644c357 100644 --- a/src/main/java/com/google/api/codegen/config/GapicInterfaceContext.java +++ b/src/main/java/com/google/api/codegen/config/GapicInterfaceContext.java @@ -246,8 +246,7 @@ public List getPublicMethods() { @Override public boolean isSupported(MethodModel method) { - boolean supported = true; - supported &= + boolean supported = getFeatureConfig().enableGrpcStreaming() || !MethodConfig.isGrpcStreamingMethod(method); supported &= getMethodConfig(method).getVisibility() != VisibilityConfig.DISABLED; return supported; diff --git a/src/main/java/com/google/api/codegen/config/GapicProductConfig.java b/src/main/java/com/google/api/codegen/config/GapicProductConfig.java index cfaac66e24..711eefbb2c 100644 --- a/src/main/java/com/google/api/codegen/config/GapicProductConfig.java +++ b/src/main/java/com/google/api/codegen/config/GapicProductConfig.java @@ -135,7 +135,7 @@ public GapicProductConfig withPackageName(String packageName) { @Nullable public static GapicProductConfig create( Model model, ConfigProto configProto, TargetLanguage language) { - return create(model, configProto, null, null, null, language, null); + return create(model, configProto, null, null, null, language, null, TransportProtocol.GRPC); } /** @@ -150,6 +150,8 @@ public static GapicProductConfig create( * generate clients for. * @param clientPackage The desired package name for the generated client. * @param language The language that this config will be used to generate a client in. + * @param grpcServiceConfig Method retries configuration. + * @param transportProtocol Transport protocol to support. */ @Nullable public static GapicProductConfig create( @@ -159,7 +161,8 @@ public static GapicProductConfig create( @Nullable String protoPackage, @Nullable String clientPackage, TargetLanguage language, - @Nullable ServiceConfig grpcServiceConfig) { + @Nullable ServiceConfig grpcServiceConfig, + TransportProtocol transportProtocol) { final String defaultPackage; SymbolTable symbolTable = model.getSymbolTable(); @@ -305,8 +308,6 @@ public static GapicProductConfig create( return null; } - TransportProtocol transportProtocol = TransportProtocol.GRPC; - String clientPackageName; LanguageSettingsProto settings = configProto.getLanguageSettingsMap().get(language.toString().toLowerCase()); diff --git a/src/main/java/com/google/api/codegen/gapic/GapicGeneratorApp.java b/src/main/java/com/google/api/codegen/gapic/GapicGeneratorApp.java index fc58aa4ddf..19a3579137 100644 --- a/src/main/java/com/google/api/codegen/gapic/GapicGeneratorApp.java +++ b/src/main/java/com/google/api/codegen/gapic/GapicGeneratorApp.java @@ -24,6 +24,7 @@ import com.google.api.codegen.config.GapicProductConfig; import com.google.api.codegen.config.PackageMetadataConfig; import com.google.api.codegen.config.PackagingConfig; +import com.google.api.codegen.config.TransportProtocol; import com.google.api.codegen.grpc.ServiceConfig; import com.google.api.codegen.samplegen.v1p2.SampleConfigProto; import com.google.api.codegen.util.MultiYamlReader; @@ -112,6 +113,14 @@ public class GapicGeneratorApp extends ToolDriverBase { "The filepath of the JSON gRPC Service Config file.", ""); + public static final Option TRANSPORT = + ToolOptions.createOption( + String.class, + "transport", + "List of transports to use ('rest' or 'grpc') separated by '+'. NOTE: For now" + + " we only support the first transport in the list.", + "grpc"); + private ArtifactType artifactType; private final GapicWriter gapicWriter; @@ -208,6 +217,16 @@ protected void process() throws Exception { } String clientPackage = Strings.emptyToNull(options.get(CLIENT_PACKAGE)); + String transport = options.get(TRANSPORT).toLowerCase(); + + TransportProtocol tp; + if (transport.equals("grpc")) { + tp = TransportProtocol.GRPC; + } else if (transport.equals("rest")) { + tp = TransportProtocol.HTTP; + } else { + throw new IllegalArgumentException("Unknown transport protocol: " + transport); + } GapicProductConfig productConfig = GapicProductConfig.create( @@ -217,7 +236,8 @@ protected void process() throws Exception { protoPackage, clientPackage, language, - gRPCServiceConfig); + gRPCServiceConfig, + tp); if (productConfig == null) { ToolUtil.reportDiags(model.getDiagReporter().getDiagCollector(), true); return; diff --git a/src/main/java/com/google/api/codegen/gapic/GapicGeneratorFactory.java b/src/main/java/com/google/api/codegen/gapic/GapicGeneratorFactory.java index 0323b70357..576c4351bf 100644 --- a/src/main/java/com/google/api/codegen/gapic/GapicGeneratorFactory.java +++ b/src/main/java/com/google/api/codegen/gapic/GapicGeneratorFactory.java @@ -262,7 +262,7 @@ public static List> create( new JavaSurfaceTestTransformer<>( javaTestPathMapper, new JavaGapicSurfaceTransformer(javaTestPathMapper), - "java/grpc_test.snip"))); + "java/test.snip"))); } } return generators; diff --git a/src/main/java/com/google/api/codegen/transformer/ApiCallableTransformer.java b/src/main/java/com/google/api/codegen/transformer/ApiCallableTransformer.java index 6ac3e49abf..9ddf162245 100644 --- a/src/main/java/com/google/api/codegen/transformer/ApiCallableTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/ApiCallableTransformer.java @@ -24,6 +24,8 @@ import com.google.api.codegen.config.MethodContext; import com.google.api.codegen.config.MethodModel; import com.google.api.codegen.config.PageStreamingConfig; +import com.google.api.codegen.config.ProtoField; +import com.google.api.codegen.config.ProtoMethodModel; import com.google.api.codegen.config.SingleResourceNameConfig; import com.google.api.codegen.config.TransportProtocol; import com.google.api.codegen.config.VisibilityConfig; @@ -33,17 +35,23 @@ import com.google.api.codegen.viewmodel.ApiCallSettingsView; import com.google.api.codegen.viewmodel.ApiCallableImplType; import com.google.api.codegen.viewmodel.ApiCallableView; +import com.google.api.codegen.viewmodel.HttpMethodSelectorView; import com.google.api.codegen.viewmodel.HttpMethodView; import com.google.api.codegen.viewmodel.LongRunningOperationDetailView; import com.google.api.codegen.viewmodel.MethodDescriptorView; import com.google.api.codegen.viewmodel.RetryCodesDefinitionView; import com.google.api.codegen.viewmodel.RetryParamsDefinitionView; import com.google.api.codegen.viewmodel.ServiceMethodType; +import com.google.api.tools.framework.aspects.http.model.HttpAttribute; +import com.google.api.tools.framework.model.Field; +import com.google.api.tools.framework.model.FieldSelector; +import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; public class ApiCallableTransformer { @@ -212,39 +220,94 @@ private void setCommonApiCallableFields( private HttpMethodView generateHttpFields(MethodContext context) { if (context.getProductConfig().getTransportProtocol().equals(TransportProtocol.HTTP)) { - Method method = ((DiscoveryMethodModel) context.getMethodModel()).getDiscoMethod(); - HttpMethodView.Builder httpMethodView = HttpMethodView.newBuilder(); - httpMethodView.fullMethodName(method.id()); - httpMethodView.httpMethod(method.httpMethod()); - List pathParams = new ArrayList<>(method.pathParams().keySet()); - List queryParams = new ArrayList<>(method.queryParams().keySet()); - Collections.sort(pathParams); - Collections.sort(queryParams); - httpMethodView.pathParams(pathParams); - httpMethodView.queryParams(queryParams); - httpMethodView.pathTemplate(method.path()); - - // TODO(andrealin): handle multiple resource names. - DiscoGapicInterfaceConfig interfaceConfig = - (DiscoGapicInterfaceConfig) context.getSurfaceInterfaceContext().getInterfaceConfig(); - SingleResourceNameConfig nameConfig = - interfaceConfig.methodToResourceNameMap().get(context.getMethodConfig()); - httpMethodView.resourceNameTypeName( - context.getNamer().publicClassName(DiscoGapicParser.getResourceNameName(nameConfig))); - // Find the field with the resource name config. - for (FieldConfig fieldConfig : context.getMethodConfig().getRequiredFieldConfigs()) { - if (fieldConfig.getResourceNameConfig() != null - && fieldConfig.getResourceNameConfig().equals(nameConfig)) { - httpMethodView.resourceNameFieldName( - context - .getNamer() - .privateFieldName(Name.anyCamel(fieldConfig.getField().getNameAsParameter()))); + if (context.getMethodModel() instanceof DiscoveryMethodModel) { + // This section is only for DiscoGapic and will be deleted once the generator stops + // ingesting Discovery files. + Method method = ((DiscoveryMethodModel) context.getMethodModel()).getDiscoMethod(); + HttpMethodView.Builder httpMethodView = HttpMethodView.newBuilder(); + httpMethodView.fullMethodName(method.id()); + httpMethodView.httpMethod(method.httpMethod()); + List pathParams = new ArrayList<>(method.pathParams().keySet()); + List queryParams = new ArrayList<>(method.queryParams().keySet()); + Collections.sort(pathParams); + Collections.sort(queryParams); + httpMethodView.pathParams(pathParams); + httpMethodView.queryParams(queryParams); + httpMethodView.pathTemplate(method.path()); + + // TODO(andrealin): handle multiple resource names. + DiscoGapicInterfaceConfig interfaceConfig = + (DiscoGapicInterfaceConfig) context.getSurfaceInterfaceContext().getInterfaceConfig(); + SingleResourceNameConfig nameConfig = + interfaceConfig.methodToResourceNameMap().get(context.getMethodConfig()); + httpMethodView.resourceNameTypeName( + context.getNamer().publicClassName(DiscoGapicParser.getResourceNameName(nameConfig))); + // Find the field with the resource name config. + for (FieldConfig fieldConfig : context.getMethodConfig().getRequiredFieldConfigs()) { + if (fieldConfig.getResourceNameConfig() != null + && fieldConfig.getResourceNameConfig().equals(nameConfig)) { + httpMethodView.resourceNameFieldName( + context + .getNamer() + .privateFieldName(Name.anyCamel(fieldConfig.getField().getNameAsParameter()))); + } } + return httpMethodView.build(); + } else if (context.getMethodModel() instanceof ProtoMethodModel) { + com.google.api.tools.framework.model.Method method = + ((ProtoMethodModel) context.getMethodModel()).getProtoMethod(); + HttpAttribute httpAttr = method.getAttribute(HttpAttribute.KEY); + + HttpMethodView.Builder httpMethodView = HttpMethodView.newBuilder(); + httpMethodView.httpMethod(httpAttr.getMethodKind().toString()); + httpMethodView.fullMethodName(httpAttr.getRestMethod().getFullName()); + + SurfaceNamer namer = context.getNamer(); + httpMethodView.pathTemplate( + httpAttr + .getPath() + .stream() + .map(pathSegment -> normalizePathSegment(pathSegment.toString())) + .collect(Collectors.joining("/", "/", ""))); + + httpMethodView.pathParamSelectors( + populateMethodSelectors(namer, httpAttr.getPathSelectors())); + httpMethodView.queryParamSelectors( + populateMethodSelectors(namer, httpAttr.getParamSelectors())); + + httpMethodView.bodySelectors(populateMethodSelectors(namer, httpAttr.getBodySelectors())); + + return httpMethodView.build(); } - return httpMethodView.build(); - } else { - return null; } + + return null; + } + + private String normalizePathSegment(String pathSegment) { + if (!pathSegment.matches("\\{\\w+}")) { + return pathSegment; + } + + return '{' + Name.from(pathSegment.substring(1, pathSegment.length() - 1)).toLowerCamel() + '}'; + } + + private List populateMethodSelectors( + SurfaceNamer namer, List selectors) { + ImmutableList.Builder paramSelectors = ImmutableList.builder(); + + for (FieldSelector fs : selectors) { + HttpMethodSelectorView.Builder methodSelectorView = HttpMethodSelectorView.newBuilder(); + methodSelectorView.fullyQualifiedName(Name.anyLower(fs.toString()).toLowerCamel()); + ImmutableList.Builder gettersChain = ImmutableList.builder(); + for (Field f : fs.getFields()) { + gettersChain.add(namer.getFieldGetFunctionName(new ProtoField(f))); + } + methodSelectorView.gettersChain(gettersChain.build()); + paramSelectors.add(methodSelectorView.build()); + } + + return paramSelectors.build(); } public List generateApiCallableSettings(MethodContext context) { diff --git a/src/main/java/com/google/api/codegen/transformer/TestCaseTransformer.java b/src/main/java/com/google/api/codegen/transformer/TestCaseTransformer.java index 33b997bc8f..e08ddf9598 100644 --- a/src/main/java/com/google/api/codegen/transformer/TestCaseTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/TestCaseTransformer.java @@ -229,6 +229,7 @@ public TestCaseView createTestCaseView( synchronicity == Synchronicity.Sync ? namer.getGrpcMethodName(method) : namer.getAsyncGrpcMethodName(method)) + .transportProtocol(methodContext.getProductConfig().getTransportProtocol()) .build(); } diff --git a/src/main/java/com/google/api/codegen/transformer/java/JavaFeatureConfig.java b/src/main/java/com/google/api/codegen/transformer/java/JavaFeatureConfig.java index 2a11fcb346..3e5800fcc5 100644 --- a/src/main/java/com/google/api/codegen/transformer/java/JavaFeatureConfig.java +++ b/src/main/java/com/google/api/codegen/transformer/java/JavaFeatureConfig.java @@ -19,22 +19,26 @@ import com.google.api.codegen.config.MethodContext; import com.google.api.codegen.config.ResourceNameMessageConfigs; import com.google.api.codegen.config.ResourceNameType; +import com.google.api.codegen.config.TransportProtocol; import com.google.api.codegen.transformer.DefaultFeatureConfig; import com.google.auto.value.AutoValue; @AutoValue public abstract class JavaFeatureConfig extends DefaultFeatureConfig { + @Override + public abstract boolean resourceNameTypesEnabled(); @Override - public abstract boolean enableStringFormatFunctions(); + public abstract boolean enableMixins(); @Override - public abstract boolean useStaticCreateMethodForOneofs(); + public abstract boolean enableGrpcStreaming(); @Override - public boolean resourceNameTypesEnabled() { - return true; - } + public abstract boolean enableStringFormatFunctions(); + + @Override + public abstract boolean useStaticCreateMethodForOneofs(); @Override public boolean useResourceNameFormatOptionInSample( @@ -73,11 +77,6 @@ public boolean useInheritanceForOneofs() { return true; } - @Override - public boolean enableMixins() { - return true; - } - @Override public boolean enableRawOperationCallSettings() { return true; @@ -89,6 +88,11 @@ public static Builder newBuilder() { @AutoValue.Builder abstract static class Builder { + abstract Builder resourceNameTypesEnabled(boolean value); + + abstract Builder enableMixins(boolean value); + + abstract Builder enableGrpcStreaming(boolean value); abstract Builder enableStringFormatFunctions(boolean value); @@ -109,7 +113,12 @@ public static JavaFeatureConfig create(GapicProductConfig productConfig) { enableStringFormatFunctions = resourceNameMessageConfigs == null || resourceNameMessageConfigs.isEmpty(); } + TransportProtocol tp = productConfig.getTransportProtocol(); + return JavaFeatureConfig.newBuilder() + .resourceNameTypesEnabled(true) + .enableMixins(tp != TransportProtocol.HTTP) + .enableGrpcStreaming(tp != TransportProtocol.HTTP) .enableStringFormatFunctions(enableStringFormatFunctions) .useStaticCreateMethodForOneofs(productConfig.getProtoParser().isProtoAnnotationsEnabled()) .build(); diff --git a/src/main/java/com/google/api/codegen/transformer/java/JavaGapicSurfaceTransformer.java b/src/main/java/com/google/api/codegen/transformer/java/JavaGapicSurfaceTransformer.java index ebd33ff558..e286e50197 100644 --- a/src/main/java/com/google/api/codegen/transformer/java/JavaGapicSurfaceTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/java/JavaGapicSurfaceTransformer.java @@ -18,6 +18,7 @@ import com.google.api.codegen.config.GapicProductConfig; import com.google.api.codegen.config.InterfaceModel; import com.google.api.codegen.config.ProtoApiModel; +import com.google.api.codegen.config.TransportProtocol; import com.google.api.codegen.gapic.GapicCodePathMapper; import com.google.api.codegen.transformer.ImportTypeTable; import com.google.api.codegen.transformer.ModelToViewTransformer; @@ -42,9 +43,11 @@ public class JavaGapicSurfaceTransformer private static final String SETTINGS_TEMPLATE_FILENAME = "java/settings.snip"; private static final String STUB_SETTINGS_TEMPLATE_FILENAME = "java/stub_settings.snip"; private static final String STUB_INTERFACE_TEMPLATE_FILENAME = "java/stub_interface.snip"; - private static final String GRPC_STUB_TEMPLATE_FILENAME = "java/grpc_stub.snip"; + private static final String STUB_TEMPLATE_FILENAME = "java/stub.snip"; private static final String GRPC_CALLABLE_FACTORY_TEMPLATE_FILENAME = "java/grpc_callable_factory.snip"; + private static final String HTTP_CALLABLE_FACTORY_TEMPLATE_FILENAME = + "java/http_callable_factory.snip"; private static final String PACKAGE_INFO_TEMPLATE_FILENAME = "java/package-info.snip"; private static final String PAGE_STREAMING_RESPONSE_TEMPLATE_FILENAME = "java/page_streaming_response.snip"; @@ -60,17 +63,23 @@ public List getTemplateFileNames() { SETTINGS_TEMPLATE_FILENAME, STUB_SETTINGS_TEMPLATE_FILENAME, STUB_INTERFACE_TEMPLATE_FILENAME, - GRPC_STUB_TEMPLATE_FILENAME, + STUB_TEMPLATE_FILENAME, GRPC_CALLABLE_FACTORY_TEMPLATE_FILENAME, + HTTP_CALLABLE_FACTORY_TEMPLATE_FILENAME, PACKAGE_INFO_TEMPLATE_FILENAME, PAGE_STREAMING_RESPONSE_TEMPLATE_FILENAME); } @Override public List transform(ProtoApiModel model, GapicProductConfig productConfig) { + String callableFactoryTemplateName = + productConfig.getTransportProtocol() == TransportProtocol.HTTP + ? HTTP_CALLABLE_FACTORY_TEMPLATE_FILENAME + : GRPC_CALLABLE_FACTORY_TEMPLATE_FILENAME; + JavaSurfaceTransformer commonSurfaceTransformer = new JavaSurfaceTransformer( - pathMapper, this, GRPC_STUB_TEMPLATE_FILENAME, GRPC_CALLABLE_FACTORY_TEMPLATE_FILENAME); + pathMapper, this, STUB_TEMPLATE_FILENAME, callableFactoryTemplateName); return commonSurfaceTransformer.transform(model, productConfig); } diff --git a/src/main/java/com/google/api/codegen/transformer/java/JavaSurfaceTestTransformer.java b/src/main/java/com/google/api/codegen/transformer/java/JavaSurfaceTestTransformer.java index c36806c97d..0c21e66af5 100644 --- a/src/main/java/com/google/api/codegen/transformer/java/JavaSurfaceTestTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/java/JavaSurfaceTestTransformer.java @@ -256,6 +256,8 @@ private ClientTestFileView createUnitTestFileView(InterfaceContext context) { !context.getInterfaceConfig().hasDefaultServiceAddress()); testClass.missingDefaultServiceScopes(!context.getInterfaceConfig().hasDefaultServiceScopes()); + testClass.transportProtocol(context.getProductConfig().getTransportProtocol()); + ClientTestFileView.Builder testFile = ClientTestFileView.newBuilder(); testFile.testClass(testClass.build()); testFile.outputPath(namer.getSourceFilePath(outputPath, name)); diff --git a/src/main/java/com/google/api/codegen/transformer/java/JavaSurfaceTransformer.java b/src/main/java/com/google/api/codegen/transformer/java/JavaSurfaceTransformer.java index 3451fe0266..3807873f56 100644 --- a/src/main/java/com/google/api/codegen/transformer/java/JavaSurfaceTransformer.java +++ b/src/main/java/com/google/api/codegen/transformer/java/JavaSurfaceTransformer.java @@ -635,6 +635,15 @@ private StaticLangRpcStubView generateRpcStubClass( stubClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance()); stubClass.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations()); + stubClass.transportProtocol(productConfig.getTransportProtocol()); + if (productConfig.getTransportProtocol() == TransportProtocol.HTTP) { + stubClass.callSettingsClassName("HttpJsonCallSettings"); + stubClass.stubCallableFactoryClassName("HttpJsonStubCallableFactory"); + } else { + stubClass.callSettingsClassName("GrpcCallSettings"); + stubClass.stubCallableFactoryClassName("GrpcStubCallableFactory"); + } + for (TypeAlias alias : apiMethodsContext.getImportTypeTable().getTypeTable().getAllImports().values()) { context.getImportTypeTable().getAndSaveNicknameFor(alias); @@ -922,8 +931,18 @@ private void addRpcStubImports(InterfaceContext context) { typeTable.saveNicknameFor("com.google.api.client.http.HttpMethods"); typeTable.saveNicknameFor("com.google.api.core.InternalApi"); typeTable.saveNicknameFor("com.google.api.pathtemplate.PathTemplate"); - typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpRequestFormatter"); - typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpResponseParser"); + String configSchemaVersion = context.getProductConfig().getConfigSchemaVersion(); + // Discogapic always uses gapic yaml of version 1.0 + if (configSchemaVersion != null && configSchemaVersion.startsWith("1.")) { + typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpRequestFormatter"); + typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMessageHttpResponseParser"); + } else { + typeTable.saveNicknameFor("com.google.api.gax.httpjson.FieldsExtractor"); + typeTable.saveNicknameFor("com.google.api.gax.httpjson.ProtoRestSerializer"); + typeTable.saveNicknameFor("com.google.api.gax.httpjson.ProtoMessageRequestFormatter"); + typeTable.saveNicknameFor("com.google.api.gax.httpjson.ProtoMessageResponseParser"); + typeTable.saveNicknameFor("java.util.HashMap"); + } typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMethodDescriptor"); typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonCallSettings"); typeTable.saveNicknameFor("com.google.api.gax.httpjson.HttpJsonStubCallableFactory"); diff --git a/src/main/java/com/google/api/codegen/viewmodel/HttpMethodSelectorView.java b/src/main/java/com/google/api/codegen/viewmodel/HttpMethodSelectorView.java new file mode 100644 index 0000000000..2f8e9a1160 --- /dev/null +++ b/src/main/java/com/google/api/codegen/viewmodel/HttpMethodSelectorView.java @@ -0,0 +1,24 @@ +package com.google.api.codegen.viewmodel; + +import com.google.auto.value.AutoValue; +import java.util.List; + +@AutoValue +public abstract class HttpMethodSelectorView { + public abstract String fullyQualifiedName(); + + public abstract List gettersChain(); + + public static HttpMethodSelectorView.Builder newBuilder() { + return new AutoValue_HttpMethodSelectorView.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder fullyQualifiedName(String val); + + public abstract Builder gettersChain(List val); + + public abstract HttpMethodSelectorView build(); + } +} diff --git a/src/main/java/com/google/api/codegen/viewmodel/HttpMethodView.java b/src/main/java/com/google/api/codegen/viewmodel/HttpMethodView.java index 745ef69a74..85b00048b9 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/HttpMethodView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/HttpMethodView.java @@ -16,11 +16,14 @@ import com.google.auto.value.AutoValue; import java.util.List; +import javax.annotation.Nullable; @AutoValue public abstract class HttpMethodView { + @Nullable public abstract List pathParams(); + @Nullable public abstract List queryParams(); // Return the HTTP method, e.g. GET, POST @@ -31,11 +34,26 @@ public abstract class HttpMethodView { public abstract String pathTemplate(); // The type name of the ResourceName used by this method. + @Nullable public abstract String resourceNameTypeName(); // The field name for the method's request object's ResourceName. + @Nullable public abstract String resourceNameFieldName(); + @Nullable + public abstract List pathParamSelectors(); + + @Nullable + public abstract List queryParamSelectors(); + + @Nullable + public abstract List bodySelectors(); + + public boolean hasBody() { + return !bodySelectors().isEmpty(); + } + public static Builder newBuilder() { return new AutoValue_HttpMethodView.Builder(); } @@ -56,6 +74,12 @@ public abstract static class Builder { public abstract Builder resourceNameFieldName(String name); + public abstract Builder pathParamSelectors(List val); + + public abstract Builder queryParamSelectors(List val); + + public abstract Builder bodySelectors(List val); + public abstract HttpMethodView build(); } } diff --git a/src/main/java/com/google/api/codegen/viewmodel/StaticLangRpcStubView.java b/src/main/java/com/google/api/codegen/viewmodel/StaticLangRpcStubView.java index 5587b14b20..54de39a996 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/StaticLangRpcStubView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/StaticLangRpcStubView.java @@ -14,6 +14,7 @@ */ package com.google.api.codegen.viewmodel; +import com.google.api.codegen.config.TransportProtocol; import com.google.auto.value.AutoValue; import java.util.List; import javax.annotation.Nullable; @@ -45,6 +46,21 @@ public abstract class StaticLangRpcStubView { public abstract String parentName(); + public abstract TransportProtocol transportProtocol(); + + public String transportProtocolName() { + if (transportProtocol() == TransportProtocol.GRPC) { + return "gRPC"; + } else if (transportProtocol() == TransportProtocol.HTTP) { + return "REST"; + } + return transportProtocol().toString(); + } + + public abstract String callSettingsClassName(); + + public abstract String stubCallableFactoryClassName(); + public static StaticLangRpcStubView.Builder newBuilder() { return new AutoValue_StaticLangRpcStubView.Builder(); } @@ -76,6 +92,12 @@ public abstract static class Builder { public abstract Builder parentName(String apiStubInterfaceName); + public abstract Builder transportProtocol(TransportProtocol transportProtocol); + + public abstract Builder callSettingsClassName(String val); + + public abstract Builder stubCallableFactoryClassName(String val); + public abstract StaticLangRpcStubView build(); } } diff --git a/src/main/java/com/google/api/codegen/viewmodel/testing/ClientTestClassView.java b/src/main/java/com/google/api/codegen/viewmodel/testing/ClientTestClassView.java index 027df6d2d9..4d57b8c27d 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/testing/ClientTestClassView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/testing/ClientTestClassView.java @@ -14,6 +14,7 @@ */ package com.google.api.codegen.viewmodel.testing; +import com.google.api.codegen.config.TransportProtocol; import com.google.api.codegen.viewmodel.ReroutedGrpcView; import com.google.auto.value.AutoValue; import java.util.List; @@ -94,6 +95,9 @@ public boolean hasMissingDefaultOptions() { @Nullable // Used in C# public abstract String grpcServiceClassName(); + @Nullable + public abstract TransportProtocol transportProtocol(); + public static Builder newBuilder() { return new AutoValue_ClientTestClassView.Builder() .apiHasUnaryUnaryMethod(false) @@ -149,6 +153,8 @@ public abstract static class Builder { public abstract Builder hasLongRunningOperations(boolean val); + public abstract Builder transportProtocol(TransportProtocol val); + public abstract ClientTestClassView build(); } } diff --git a/src/main/java/com/google/api/codegen/viewmodel/testing/TestCaseView.java b/src/main/java/com/google/api/codegen/viewmodel/testing/TestCaseView.java index b8f731ae2d..39221fd340 100644 --- a/src/main/java/com/google/api/codegen/viewmodel/testing/TestCaseView.java +++ b/src/main/java/com/google/api/codegen/viewmodel/testing/TestCaseView.java @@ -15,6 +15,7 @@ package com.google.api.codegen.viewmodel.testing; import com.google.api.codegen.config.GrpcStreamingConfig.GrpcStreamingType; +import com.google.api.codegen.config.TransportProtocol; import com.google.api.codegen.viewmodel.ClientMethodType; import com.google.api.codegen.viewmodel.InitCodeView; import com.google.auto.value.AutoValue; @@ -85,6 +86,9 @@ public abstract class TestCaseView { public abstract String grpcMethodName(); + @Nullable + public abstract TransportProtocol transportProtocol(); + public static Builder newBuilder() { return new AutoValue_TestCaseView.Builder(); } @@ -146,6 +150,8 @@ public abstract static class Builder { public abstract Builder grpcMethodName(String val); + public abstract Builder transportProtocol(TransportProtocol val); + public abstract TestCaseView build(); } } diff --git a/src/main/resources/com/google/api/codegen/java/http_callable_factory.snip b/src/main/resources/com/google/api/codegen/java/http_callable_factory.snip index a2a31b7d97..a5d32ac6ad 100644 --- a/src/main/resources/com/google/api/codegen/java/http_callable_factory.snip +++ b/src/main/resources/com/google/api/codegen/java/http_callable_factory.snip @@ -26,7 +26,7 @@ @private classDoc(doc) // AUTO-GENERATED DOCUMENTATION AND CLASS /** - * HTTP callable factory implementation for {@doc.serviceTitle}. + * REST callable factory implementation for {@doc.serviceTitle}. * *

This class is for advanced usage. */ diff --git a/src/main/resources/com/google/api/codegen/java/grpc_stub.snip b/src/main/resources/com/google/api/codegen/java/stub.snip similarity index 68% rename from src/main/resources/com/google/api/codegen/java/grpc_stub.snip rename to src/main/resources/com/google/api/codegen/java/stub.snip index 720c44453c..ac3ad6b5d1 100644 --- a/src/main/resources/com/google/api/codegen/java/grpc_stub.snip +++ b/src/main/resources/com/google/api/codegen/java/stub.snip @@ -10,7 +10,7 @@ @snippet generate(classFile) {@renderStubFileHeader(classFile.fileHeader)} - {@classDoc(classFile.classView.doc)} + {@classDoc(classFile.classView)} @@Generated("by gapic-generator") # TODO once stub classes are stable, start using releaseLevelAnnotation #@if classFile.classView.releaseLevelAnnotation @@ -31,10 +31,10 @@ } @end -@private classDoc(doc) +@private classDoc(classView) // AUTO-GENERATED DOCUMENTATION AND CLASS /** - * gRPC stub implementation for {@doc.serviceTitle}. + * {@classView.transportProtocolName} stub implementation for {@classView.doc.serviceTitle}. * *

This class is for advanced usage and reflects the underlying API directly. */ @@ -43,7 +43,11 @@ @private constants(stubClass) @join methodDescriptor : stubClass.methodDescriptors - {@grpcMethodDescriptor(methodDescriptor)} + @if stubClass.transportProtocol == "HTTP" + {@httpMethodDescriptor(methodDescriptor)} + @else + {@grpcMethodDescriptor(methodDescriptor)} + @end @end {@""} @end @@ -58,6 +62,79 @@ .build(); @end +@private httpMethodDescriptor(methodDescriptor) + @@InternalApi + public static final ApiMethodDescriptor<{@methodDescriptor.requestTypeName}, {@methodDescriptor.responseTypeName}> {@methodDescriptor.name} = + ApiMethodDescriptor.<{@methodDescriptor.requestTypeName}, {@methodDescriptor.responseTypeName}>newBuilder() + .setFullMethodName("{@methodDescriptor.httpMethod.fullMethodName}") + .setHttpMethod(HttpMethods.{@methodDescriptor.httpMethod.httpMethod}) + .setRequestFormatter( + ProtoMessageRequestFormatter.<{@methodDescriptor.requestTypeName}>newBuilder() + .setPath( + "{@methodDescriptor.httpMethod.pathTemplate}", + new FieldsExtractor<{@methodDescriptor.requestTypeName}, Map>() { + @@Override + public Map extract({@methodDescriptor.requestTypeName} request) { + Map fields = new HashMap<>(); + ProtoRestSerializer<{@methodDescriptor.requestTypeName}> serializer = + ProtoRestSerializer.create(); + {@pathMethodSelectors(methodDescriptor.httpMethod.pathParamSelectors)} + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor<{@methodDescriptor.requestTypeName}, Map>>() { + @@Override + public Map> extract({@methodDescriptor.requestTypeName} request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer<{@methodDescriptor.requestTypeName}> serializer = + ProtoRestSerializer.create(); + {@queryMethodSelectors(methodDescriptor.httpMethod.queryParamSelectors)} + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor<{@methodDescriptor.requestTypeName}, String>() { + @@Override + public String extract({@methodDescriptor.requestTypeName} request) { + {@bodyMethodSelector(methodDescriptor.httpMethod)} + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.<{@methodDescriptor.responseTypeName}>newBuilder() + .setDefaultInstance({@methodDescriptor.responseTypeName}.getDefaultInstance()) + .build()) + .build(); +@end + +@private pathMethodSelectors(methodSelectors) + @join methodSelector : @methodSelectors + serializer.putPathParam(fields, "{@methodSelector.fullyQualifiedName}", request.{@methodSelectorGetter(methodSelector.gettersChain)}); + @end +@end + +@private queryMethodSelectors(methodSelectors) + @join methodSelector : @methodSelectors + serializer.putQueryParam(fields, "{@methodSelector.fullyQualifiedName}", request.{@methodSelectorGetter(methodSelector.gettersChain)}); + @end +@end + +@private bodyMethodSelector(httpMethod) + @if httpMethod.hasBody + return ProtoRestSerializer.create().toBody("{@httpMethod.bodySelectors.get(0).fullyQualifiedName}", request.{@methodSelectorGetter(httpMethod.bodySelectors.get(0).gettersChain)}); + @else + return ""; + @end +@end + +@private methodSelectorGetter(gettersChain) + @join getter : gettersChain on "." + {@getter}() + @end +@end + + @private streamingTypeEnum(streamingType) @switch streamingType @case "NonStreaming" @@ -84,7 +161,7 @@ {@apiCallableMember(apiCallable)} @end - private final GrpcStubCallableFactory callableFactory; + private final {@stubClass.stubCallableFactoryClassName} callableFactory; @end @private apiCallableMember(callable) @@ -136,7 +213,7 @@ return new {@stubClass.name}({@stubClass.stubSettingsClassName}.newBuilder().build(), clientContext); } - public static final {@stubClass.name} create(ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + public static final {@stubClass.name} create(ClientContext clientContext, {@stubClass.stubCallableFactoryClassName} callableFactory) throws IOException { return new {@stubClass.name}({@stubClass.stubSettingsClassName}.newBuilder().build(), clientContext, callableFactory); } @@ -154,15 +231,15 @@ * This is protected so that it is easy to make a subclass, but otherwise, the static * factory methods should be preferred. */ - protected {@stubClass.name}({@stubClass.stubSettingsClassName} settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + protected {@stubClass.name}({@stubClass.stubSettingsClassName} settings, ClientContext clientContext, {@stubClass.stubCallableFactoryClassName} callableFactory) throws IOException { this.callableFactory = callableFactory; @if stubClass.hasLongRunningOperations this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); @end @join methodDescriptor : stubClass.methodDescriptors - GrpcCallSettings<{@methodDescriptor.requestTypeName}, {@methodDescriptor.responseTypeName}> {@methodDescriptor.transportSettingsVar} = - GrpcCallSettings.<{@methodDescriptor.requestTypeName}, {@methodDescriptor.responseTypeName}>newBuilder() + {@stubClass.callSettingsClassName}<{@methodDescriptor.requestTypeName}, {@methodDescriptor.responseTypeName}> {@methodDescriptor.transportSettingsVar} = + {@stubClass.callSettingsClassName}.<{@methodDescriptor.requestTypeName}, {@methodDescriptor.responseTypeName}>newBuilder() .setMethodDescriptor({@methodDescriptor.name}) @if methodDescriptor.hasHeaderRequestParams .setParamsExtractor( diff --git a/src/main/resources/com/google/api/codegen/java/grpc_test.snip b/src/main/resources/com/google/api/codegen/java/test.snip similarity index 76% rename from src/main/resources/com/google/api/codegen/java/grpc_test.snip rename to src/main/resources/com/google/api/codegen/java/test.snip index 3a44db5ffe..f2f2d5ddd7 100644 --- a/src/main/resources/com/google/api/codegen/java/grpc_test.snip +++ b/src/main/resources/com/google/api/codegen/java/test.snip @@ -6,19 +6,34 @@ @@javax.annotation.Generated("by GAPIC") public class {@xapiTest.testClass.name} { - @join mockService : xapiTest.testClass.mockServices + @if xapiTest.testClass.transportProtocol == "HTTP" + {@httpTestInitialization(xapiTest.testClass)} + @else + {@grpcTestInitialization(xapiTest.testClass)} + @end + + @join test : xapiTest.testClass.testCases + {@testCase(test)} + + @end + } +@end + +@private grpcTestInitialization(testClass) + @join mockService : testClass.mockServices private static {@mockService.className} {@mockService.varName}; @end + private static MockServiceHelper serviceHelper; - private {@xapiTest.testClass.apiClassName} client; + private {@testClass.apiClassName} client; private LocalChannelProvider channelProvider; @@BeforeClass public static void startStaticServer() { - @join mockService : xapiTest.testClass.mockServices + @join mockService : testClass.mockServices {@mockService.varName} = new {@mockService.className}(); @end - serviceHelper = new MockServiceHelper(UUID.randomUUID().toString(), Arrays.asList({@mockServiceArgs(xapiTest.testClass.mockServices)})); + serviceHelper = new MockServiceHelper(UUID.randomUUID().toString(), Arrays.asList({@mockServiceArgs(testClass.mockServices)})); serviceHelper.start(); } @@ -31,23 +46,54 @@ public void setUp() throws IOException { serviceHelper.reset(); channelProvider = serviceHelper.createChannelProvider(); - {@xapiTest.testClass.apiSettingsClassName} settings = {@xapiTest.testClass.apiSettingsClassName}.newBuilder() + {@testClass.apiSettingsClassName} settings = {@testClass.apiSettingsClassName}.newBuilder() .setTransportChannelProvider(channelProvider) .setCredentialsProvider(NoCredentialsProvider.create()) .build(); - client = {@xapiTest.testClass.apiClassName}.create(settings); + client = {@testClass.apiClassName}.create(settings); } @@After public void tearDown() throws Exception { client.close(); } +@end - @join test : xapiTest.testClass.testCases - {@testCase(test)} +@private httpTestInitialization(testClass) + private static final List METHOD_DESCRIPTORS = ImmutableList.copyOf( + Lists.newArrayList( + @join test : testClass.testCases on ", ".add(BREAK) + {@test.methodDescriptor} + @end + )); + private static final MockHttpService mockService + = new MockHttpService(METHOD_DESCRIPTORS, {@testClass.apiStubSettingsClassName}.getDefaultEndpoint()); - @end - } + private static {@testClass.apiClassName} client; + private static {@testClass.apiSettingsClassName} clientSettings; + + @@BeforeClass + public static void setUp() throws IOException { + clientSettings = + {@testClass.apiSettingsClassName}.newBuilder() + .setTransportChannelProvider( + {@testClass.apiSettingsClassName}.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService).build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = + {@testClass.apiClassName}.create(clientSettings); + } + + @@After + public void cleanUp() { + mockService.reset(); + } + + @@AfterClass + public static void tearDown() throws Exception { + client.close(); + } @end @private mockServiceArgs(mockServices) @@ -252,12 +298,21 @@ @private addResponse(test) {@initCode(test.mockResponse.rpcResponseInitCode)} - {@test.mockServiceVarName}.addResponse(expectedResponse); + @if test.transportProtocol == "HTTP" + mockService.addResponse(expectedResponse); + @else + {@test.mockServiceVarName}.addResponse(expectedResponse); + @end @end @private addException(test) - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - {@test.mockServiceVarName}.addException(exception); + @if test.transportProtocol == "HTTP" + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + @else + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + {@test.mockServiceVarName}.addException(exception); + @end @end @private pagedMethodCall(test) @@ -297,6 +352,14 @@ @end @private unarySuccessAsserts(test) + @if test.transportProtocol == "HTTP" + {@httpUnarySuccessAsserts(test)} + @else + {@grpcUnarySuccessAsserts(test)} + @end +@end + +@private grpcUnarySuccessAsserts(test) List actualRequests = {@test.mockServiceVarName}.getRequests(); Assert.assertEquals(1, actualRequests.size()); {@test.requestTypeName} actualRequest = ({@test.requestTypeName})actualRequests.get(0); @@ -316,6 +379,16 @@ @end @end +@private httpUnarySuccessAsserts(test) + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); +@end + @private assertExpectedParam(assert) @if assert.hasExpectedValueTransformFunction {@assert.expectedValueTransformFunction}({@assert.expectedValueIdentifier}) diff --git a/src/test/java/com/google/api/codegen/config/GapicConfigProducerTest.java b/src/test/java/com/google/api/codegen/config/GapicConfigProducerTest.java index cfe57d8fe3..2bc6a03260 100644 --- a/src/test/java/com/google/api/codegen/config/GapicConfigProducerTest.java +++ b/src/test/java/com/google/api/codegen/config/GapicConfigProducerTest.java @@ -49,7 +49,8 @@ public void missingConfigSchemaVersion() { model.getDiagReporter().getDiagCollector(), locator, new String[] {"missing_config_schema_version.yaml"}); - GapicProductConfig.create(model, configProto, null, null, null, TargetLanguage.JAVA, null); + GapicProductConfig.create( + model, configProto, null, null, null, TargetLanguage.JAVA, null, TransportProtocol.GRPC); Diag expectedError = Diag.error( SimpleLocation.TOPLEVEL, "config_schema_version field is required in GAPIC yaml."); @@ -70,11 +71,13 @@ public void missingInterface() { model.getDiagReporter().getDiagCollector(), locator, new String[] {"missing_interface_v1.yaml"}); - GapicProductConfig.create(model, configProto, null, null, null, TargetLanguage.JAVA, null); + GapicProductConfig.create( + model, configProto, null, null, null, TargetLanguage.JAVA, null, TransportProtocol.GRPC); Diag expectedError = Diag.error( SimpleLocation.TOPLEVEL, - "interface not found: google.example.myproto.v1.MyUnknownProto. Interfaces: [google.example.myproto.v1.MyProto]"); + "interface not found: google.example.myproto.v1.MyUnknownProto. Interfaces:" + + " [google.example.myproto.v1.MyProto]"); assertThat(model.getDiagReporter().getDiagCollector().hasErrors()).isTrue(); assertThat(model.getDiagReporter().getDiagCollector().getDiags()).contains(expectedError); } @@ -111,7 +114,8 @@ public void testCreateProductWithGRPCServiceConfig() { "google.example.library.v1", null, TargetLanguage.GO, - serviceConfig); + serviceConfig, + TransportProtocol.GRPC); assertThat(model.getDiagReporter().getDiagCollector().hasErrors()).isFalse(); assertThat(product).isNotNull(); diff --git a/src/test/java/com/google/api/codegen/discogapic/testdata/java/java_simplecompute.v1.json.baseline b/src/test/java/com/google/api/codegen/discogapic/testdata/java/java_simplecompute.v1.json.baseline index a778467dea..b6ecd68503 100644 --- a/src/test/java/com/google/api/codegen/discogapic/testdata/java/java_simplecompute.v1.json.baseline +++ b/src/test/java/com/google/api/codegen/discogapic/testdata/java/java_simplecompute.v1.json.baseline @@ -11305,7 +11305,7 @@ import javax.annotation.Nullable; // AUTO-GENERATED DOCUMENTATION AND CLASS /** - * HTTP callable factory implementation for simplecompute. + * REST callable factory implementation for simplecompute. * *

This class is for advanced usage. */ diff --git a/src/test/java/com/google/api/codegen/gapic/GapicCodeGeneratorTest.java b/src/test/java/com/google/api/codegen/gapic/GapicCodeGeneratorTest.java index fb221a8a2d..0744b6568a 100644 --- a/src/test/java/com/google/api/codegen/gapic/GapicCodeGeneratorTest.java +++ b/src/test/java/com/google/api/codegen/gapic/GapicCodeGeneratorTest.java @@ -16,6 +16,7 @@ import com.google.api.codegen.CodegenTestUtil; import com.google.api.codegen.common.TargetLanguage; +import com.google.api.codegen.config.TransportProtocol; import java.util.Arrays; import java.util.List; import org.junit.Test; @@ -39,6 +40,7 @@ public GapicCodeGeneratorTest( String protoPackage, String clientPackage, String grpcServiceConfigFileName, + TransportProtocol transportProtocol, String[] baseNames) { super( language, @@ -49,13 +51,14 @@ public GapicCodeGeneratorTest( baseline, protoPackage, clientPackage, - grpcServiceConfigFileName); + grpcServiceConfigFileName, + transportProtocol); this.baseNames = baseNames; getTestDataLocator().addTestDataSource(CodegenTestUtil.class, "testsrc/gapicconfig"); getTestDataLocator().addTestDataSource(CodegenTestUtil.class, "testsrc/gapicconfig/samples"); } - @Parameters(name = "{5}") + @Parameters(name = "{6}") public static List testedConfigs() { return Arrays.asList( GapicTestBase2.createTestConfig( @@ -64,19 +67,22 @@ public static List testedConfigs() { null, "library", null, + TransportProtocol.GRPC, "another_service"), GapicTestBase2.createTestConfig( TargetLanguage.PHP, new String[] {"longrunning_gapic.yaml"}, "longrunning_pkg2.yaml", "longrunning", - null), // Test passing in a proto_package flag. + null, + TransportProtocol.GRPC), // Test passing in a proto_package flag. GapicTestBase2.createTestConfig( TargetLanguage.PHP, new String[] {"no_path_templates_gapic.yaml"}, "no_path_templates_pkg2.yaml", "no_path_templates", - null), + null, + TransportProtocol.GRPC), GapicTestBase2.createTestConfig( TargetLanguage.PHP, new String[] {"library_gapic.yaml"}, @@ -87,6 +93,7 @@ public static List testedConfigs() { null, sampleConfigFileNames(), "php_library.baseline", + TransportProtocol.GRPC, new String[] {"another_service"}), GapicTestBase2.createTestConfig( TargetLanguage.JAVA, @@ -94,19 +101,22 @@ public static List testedConfigs() { "multiple_services_pkg2.yaml", "multiple_services", null, + TransportProtocol.GRPC, "multiple_services_v2"), GapicTestBase2.createTestConfig( TargetLanguage.JAVA, new String[] {"no_path_templates_gapic.yaml"}, "no_path_templates_pkg2.yaml", "no_path_templates", - null), + null, + TransportProtocol.GRPC), GapicTestBase2.createTestConfig( TargetLanguage.JAVA, new String[] {"my_streaming_proto_gapic.yaml"}, "my_streaming_proto_pkg2.yaml", "my_streaming_proto", - null), + null, + TransportProtocol.GRPC), GapicTestBase2.createTestConfig( TargetLanguage.JAVA, new String[] {"library_gapic.yaml"}, @@ -117,6 +127,7 @@ public static List testedConfigs() { null, sampleConfigFileNames(), "java_library.baseline", + TransportProtocol.GRPC, new String[] {"another_service"}), GapicTestBase2.createTestConfig( TargetLanguage.RUBY, @@ -124,13 +135,15 @@ public static List testedConfigs() { "multiple_services_pkg2.yaml", "multiple_services", null, + TransportProtocol.GRPC, "multiple_services_v2"), GapicTestBase2.createTestConfig( TargetLanguage.RUBY, new String[] {"longrunning_gapic.yaml"}, "longrunning_pkg2.yaml", "longrunning", - null), + null, + TransportProtocol.GRPC), GapicTestBase2.createTestConfig( TargetLanguage.RUBY, new String[] {"library_gapic.yaml"}, @@ -141,19 +154,22 @@ public static List testedConfigs() { null, sampleConfigFileNames(), "ruby_library.baseline", + TransportProtocol.GRPC, new String[] {"another_service"}), GapicTestBase2.createTestConfig( TargetLanguage.PYTHON, new String[] {"no_path_templates_gapic.yaml"}, "no_path_templates_pkg2.yaml", "no_path_templates", - null), + null, + TransportProtocol.GRPC), GapicTestBase2.createTestConfig( TargetLanguage.PYTHON, new String[] {"multiple_services_gapic.yaml"}, "multiple_services_pkg2.yaml", "multiple_services", null, + TransportProtocol.GRPC, "multiple_services_v2"), GapicTestBase2.createTestConfig( TargetLanguage.PYTHON, @@ -165,19 +181,22 @@ public static List testedConfigs() { null, sampleConfigFileNames(), "python_library.baseline", + TransportProtocol.GRPC, new String[] {"another_service"}), GapicTestBase2.createTestConfig( TargetLanguage.NODEJS, new String[] {"no_path_templates_gapic.yaml"}, "library_pkg2.yaml", "no_path_templates", - null), + null, + TransportProtocol.GRPC), GapicTestBase2.createTestConfig( TargetLanguage.NODEJS, new String[] {"multiple_services_gapic.yaml"}, "multiple_services_pkg2.yaml", "multiple_services", null, + TransportProtocol.GRPC, "multiple_services_v2"), GapicTestBase2.createTestConfig( TargetLanguage.NODEJS, @@ -189,6 +208,7 @@ public static List testedConfigs() { null, sampleConfigFileNames(), "nodejs_library.baseline", + TransportProtocol.GRPC, new String[] {"another_service"}), GapicTestBase2.createTestConfig( TargetLanguage.CSHARP, @@ -200,6 +220,7 @@ public static List testedConfigs() { null, sampleConfigFileNames(), "csharp_library.baseline", + TransportProtocol.GRPC, new String[] {"another_service"})); } diff --git a/src/test/java/com/google/api/codegen/gapic/GapicTestBase2.java b/src/test/java/com/google/api/codegen/gapic/GapicTestBase2.java index 6fa330ac6a..85449e6d3c 100644 --- a/src/test/java/com/google/api/codegen/gapic/GapicTestBase2.java +++ b/src/test/java/com/google/api/codegen/gapic/GapicTestBase2.java @@ -27,6 +27,7 @@ import com.google.api.codegen.config.GapicProductConfig; import com.google.api.codegen.config.PackageMetadataConfig; import com.google.api.codegen.config.PackagingConfig; +import com.google.api.codegen.config.TransportProtocol; import com.google.api.codegen.grpc.ServiceConfig; import com.google.api.codegen.samplegen.v1p2.SampleConfigProto; import com.google.api.tools.framework.model.Diag; @@ -68,6 +69,7 @@ public abstract class GapicTestBase2 extends ConfigBaselineTestCase { private final TestDataLocator testDataLocator = MixedPathTestDataLocator.create(this.getClass()); private final String grpcServiceConfigFileName; private ServiceConfig grpcServiceConfig; + private final TransportProtocol transportProtocol; public GapicTestBase2( TargetLanguage language, @@ -78,7 +80,8 @@ public GapicTestBase2( String baselineFile, String protoPackage, String clientPackage, - String grpcServiceConfigFileName) { + String grpcServiceConfigFileName, + TransportProtocol transportProtocol) { this.language = language; this.gapicConfigFileNames = gapicConfigFileNames; this.sampleConfigFileNames = sampleConfigFileNames; @@ -90,6 +93,7 @@ public GapicTestBase2( // Represents the test value for the --package flag. this.protoPackage = protoPackage; + this.transportProtocol = transportProtocol; String dir = language.toString().toLowerCase(); if ("python".equals(dir)) { @@ -179,6 +183,7 @@ static Object[] createTestConfig( String packageConfigFileName, String apiName, String grpcServiceConfigFileName, + TransportProtocol transportProtocol, String... baseNames) { return createTestConfig( language, @@ -190,6 +195,7 @@ static Object[] createTestConfig( grpcServiceConfigFileName, null, null, + transportProtocol, baseNames); } @@ -210,6 +216,7 @@ public static Object[] createTestConfig( String grpcServiceConfigFileName, String[] sampleConfigFileNames, String baseline, + TransportProtocol transportProtocol, String... baseNames) { Model model = Model.create(Service.getDefaultInstance()); GapicProductConfig productConfig = GapicProductConfig.createDummyInstance(); @@ -254,6 +261,7 @@ public static Object[] createTestConfig( protoPackage, clientPackage, grpcServiceConfigFileName, + transportProtocol, baseNames }; } @@ -283,7 +291,8 @@ protected String baselineFileName() { protoPackage, clientPackage, language, - grpcServiceConfig); + grpcServiceConfig, + transportProtocol); if (productConfig == null) { for (Diag diag : model.getDiagReporter().getDiagCollector().getDiags()) { diff --git a/src/test/java/com/google/api/codegen/gapic/ProtocGapicPluginGeneratorTest.java b/src/test/java/com/google/api/codegen/gapic/ProtocGapicPluginGeneratorTest.java index 2a6f3ce9cf..8fef060ffe 100644 --- a/src/test/java/com/google/api/codegen/gapic/ProtocGapicPluginGeneratorTest.java +++ b/src/test/java/com/google/api/codegen/gapic/ProtocGapicPluginGeneratorTest.java @@ -53,7 +53,7 @@ public void testGenerator() { model.getFiles().stream().map(ProtoFile::getProto).collect(Collectors.toList())) // Only the file to generate a client for (don't generate dependencies) .addFileToGenerate("multiple_services.proto") - .setParameter("language=java") + .setParameter("language=java,transport=grpc") .build(); CodeGeneratorResponse response = ProtocGeneratorMain.generate(codeGeneratorRequest); @@ -73,6 +73,7 @@ public void testFailingGenerator() { model.getFiles().stream().map(ProtoFile::getProto).collect(Collectors.toList())) // File does not exist. .addFileToGenerate("fuuuuudge.proto") + .setParameter("transport=rest") .build(); CodeGeneratorResponse response = ProtocGeneratorMain.generate(codeGeneratorRequest); diff --git a/src/test/java/com/google/api/codegen/protoannotations/GapicCodeGeneratorAnnotationsTest.java b/src/test/java/com/google/api/codegen/protoannotations/GapicCodeGeneratorAnnotationsTest.java index f5fc17858b..1d69c99b6d 100644 --- a/src/test/java/com/google/api/codegen/protoannotations/GapicCodeGeneratorAnnotationsTest.java +++ b/src/test/java/com/google/api/codegen/protoannotations/GapicCodeGeneratorAnnotationsTest.java @@ -16,6 +16,7 @@ import com.google.api.codegen.CodegenTestUtil; import com.google.api.codegen.common.TargetLanguage; +import com.google.api.codegen.config.TransportProtocol; import com.google.api.codegen.gapic.GapicTestBase2; import java.util.Arrays; import java.util.List; @@ -44,6 +45,7 @@ public GapicCodeGeneratorAnnotationsTest( String protoPackage, String clientPackage, String grpcServiceConfigFileName, + TransportProtocol transportProtocol, String[] baseNames) { super( language, @@ -54,7 +56,8 @@ public GapicCodeGeneratorAnnotationsTest( baseline, protoPackage, clientPackage, - grpcServiceConfigFileName); + grpcServiceConfigFileName, + transportProtocol); String apiName = baseNames[0]; @@ -88,6 +91,20 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, + "common_resources", + "another_service"), + GapicTestBase2.createTestConfig( + TargetLanguage.JAVA, + null, + "library_pkg2.yaml", + "library", + "google.example.library.v1", + "com.google.example.library.v1", + null, + null, + "java_library_no_gapic_config_http.baseline", + TransportProtocol.HTTP, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -100,6 +117,7 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -112,6 +130,7 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -124,6 +143,7 @@ public static List testedConfigs() { "library_grpc_service_config.json", null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -136,6 +156,7 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -148,6 +169,7 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -160,6 +182,7 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -172,6 +195,7 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -184,6 +208,7 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -196,6 +221,7 @@ public static List testedConfigs() { "library_grpc_service_config.json", null, null, + TransportProtocol.GRPC, "common_resources", "another_service"), GapicTestBase2.createTestConfig( @@ -208,6 +234,7 @@ public static List testedConfigs() { null, null, null, + TransportProtocol.GRPC, "common_resources", "another_service")); } diff --git a/src/test/java/com/google/api/codegen/protoannotations/testdata/java_library_no_gapic_config_http.baseline b/src/test/java/com/google/api/codegen/protoannotations/testdata/java_library_no_gapic_config_http.baseline new file mode 100644 index 0000000000..8e2706a101 --- /dev/null +++ b/src/test/java/com/google/api/codegen/protoannotations/testdata/java_library_no_gapic_config_http.baseline @@ -0,0 +1,13144 @@ +============== file: ../build.gradle ============== +Static or binary file content is not shown. +============== file: ../gradle/wrapper/gradle-wrapper.jar ============== +Static or binary file content is not shown. +============== file: ../gradle/wrapper/gradle-wrapper.properties ============== +Static or binary file content is not shown. +============== file: ../gradlew ============== +Static or binary file content is not shown. +============== file: ../gradlew.bat ============== +Static or binary file content is not shown. +============== file: ../settings.gradle ============== +Static or binary file content is not shown. +============== file: build.gradle ============== +buildscript { + repositories { + mavenCentral() + } +} + +apply plugin: 'java' + +description = 'GAPIC library for google-cloud-library-v1' +group = 'com.google.cloud' +version = (findProperty('version') == 'unspecified') ? '0.0.0-SNAPSHOT' : version +sourceCompatibility = 1.7 +targetCompatibility = 1.7 + +repositories { + mavenCentral() + mavenLocal() +} + +compileJava.options.encoding = 'UTF-8' +javadoc.options.encoding = 'UTF-8' + +dependencies { + compile 'com.google.api:gax:1.0.0' + testCompile 'com.google.api:gax:1.0.0:testlib' + compile 'com.google.api:gax-grpc:0.18.0' + testCompile 'com.google.api:gax-grpc:0.18.0:testlib' + testCompile 'io.grpc:grpc-netty-shaded:1.9.0' + testCompile 'junit:junit:4.12' + // Remove this line if you are bundling your proto-generated classes together with your client classes + compile project(':proto-google-cloud-library-v1') + // Remove this line if you are bundling your proto-generated classes together with your client classes + testCompile project(':grpc-google-cloud-library-v1') + testCompile 'com.google.api.grpc:grpc-google-some-test-package-v1:0.0.0' +} + +task smokeTest(type: Test) { + filter { + includeTestsMatching "*SmokeTest" + setFailOnNoMatchingTests false + } +} + +test { + exclude "**/*SmokeTest*" +} + +sourceSets { + main { + java { + srcDir 'src/main/java' + } + } +} + +clean { + delete 'all-jars' +} + +task allJars(type: Copy) { + dependsOn test, jar + into 'all-jars' + // Replace with `from configurations.testRuntime, jar` to include test dependencies + from configurations.runtime, jar +} +============== file: src/main/java/com/google/example/library/v1/LibraryServiceClient.java ============== +/* + * 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.example.library.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.paging.FixedSizeCollection; +import com.google.api.gax.paging.Page; +import com.google.api.gax.rpc.ApiExceptions; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Function; +import com.google.common.collect.Iterables; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.example.library.v1.Book; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest.InnerMessage; +import com.google.example.library.v1.stub.LibraryServiceStub; +import com.google.example.library.v1.stub.LibraryServiceStubSettings; +import com.google.longrunning.Operation; +import com.google.longrunning.OperationsClient; +import com.google.protobuf.Any; +import com.google.protobuf.BoolValue; +import com.google.protobuf.ByteString; +import com.google.protobuf.BytesValue; +import com.google.protobuf.DoubleValue; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.FloatValue; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Int64Value; +import com.google.protobuf.ListValue; +import com.google.protobuf.StringValue; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; +import com.google.protobuf.UInt32Value; +import com.google.protobuf.UInt64Value; +import com.google.protobuf.Value; +import com.google.tagger.v1.TaggerProto.AddTagRequest; +import com.google.tagger.v1.TaggerProto.AddTagResponse; +import java.io.Closeable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: This API represents a simple digital library. It lets you manage Shelf + * resources and Book resources in the library. It defines the following + * resource model: + * + * - The API has a collection of [Shelf][google.example.library.v1.Shelf] + * resources, named ``bookShelves/*`` + * + * - Each Shelf has a collection of [Book][google.example.library.v1.Book] + * resources, named `bookShelves/*/books/*` + * + * Check out [cloud docs!](/library/example/link). + * This is [not a cloud link](http://www.google.com). + * + * Service comment may include special characters: <>&"`'{@literal @}. + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+ *   Shelf shelf = Shelf.newBuilder().build();
+ *   Shelf response = libraryServiceClient.createShelf(shelf);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the libraryServiceClient object to clean up resources such + * as threads. In the example above, try-with-resources is used, which automatically calls + * close(). + * + *

The surface of this class includes several types of Java methods for each of the API's methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available + * as parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request + * object, which must be constructed before the call. Not every API method will have a request + * object method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable + * API callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist + * with these names, this class includes a format method for each type of name, and additionally + * a parse method to extract the individual identifiers contained within names that are + * returned. + * + *

This class can be customized by passing in a custom instance of LibraryServiceSettings to + * create(). For example: + * + * To customize credentials: + * + *

+ * 
+ * LibraryServiceSettings libraryServiceSettings =
+ *     LibraryServiceSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * LibraryServiceClient libraryServiceClient =
+ *     LibraryServiceClient.create(libraryServiceSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * LibraryServiceSettings libraryServiceSettings =
+ *     LibraryServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * LibraryServiceClient libraryServiceClient =
+ *     LibraryServiceClient.create(libraryServiceSettings);
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class LibraryServiceClient implements BackgroundResource { + private final LibraryServiceSettings settings; + private final LibraryServiceStub stub; + private final OperationsClient operationsClient; + + + + /** + * Constructs an instance of LibraryServiceClient with default settings. + */ + public static final LibraryServiceClient create() throws IOException { + return create(LibraryServiceSettings.newBuilder().build()); + } + + /** + * Constructs an instance of LibraryServiceClient, using the given settings. + * The channels are created based on the settings passed in, or defaults for any + * settings that are not set. + */ + public static final LibraryServiceClient create(LibraryServiceSettings settings) throws IOException { + return new LibraryServiceClient(settings); + } + + /** + * Constructs an instance of LibraryServiceClient, using the given stub for making calls. This is for + * advanced usage - prefer to use LibraryServiceSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final LibraryServiceClient create(LibraryServiceStub stub) { + return new LibraryServiceClient(stub); + } + + /** + * Constructs an instance of LibraryServiceClient, using the given settings. + * This is protected so that it is easy to make a subclass, but otherwise, the static + * factory methods should be preferred. + */ + protected LibraryServiceClient(LibraryServiceSettings settings) throws IOException { + this.settings = settings; + this.stub = ((LibraryServiceStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected LibraryServiceClient(LibraryServiceStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + } + + public final LibraryServiceSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public LibraryServiceStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running + * operation returned by another API method call. + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationsClient getOperationsClient() { + return operationsClient; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a shelf, and returns the new Shelf. + * RPC method comment may include special characters: <>&"`'{@literal @}. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   Shelf shelf = Shelf.newBuilder().build();
+   *   Shelf response = libraryServiceClient.createShelf(shelf);
+   * }
+   * 
+ * + * @param shelf The shelf to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf createShelf(Shelf shelf) { + CreateShelfRequest request = + CreateShelfRequest.newBuilder() + .setShelf(shelf) + .build(); + return createShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a shelf, and returns the new Shelf. + * RPC method comment may include special characters: <>&"`'{@literal @}. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   Shelf shelf = Shelf.newBuilder().build();
+   *   CreateShelfRequest request = CreateShelfRequest.newBuilder()
+   *     .setShelf(shelf)
+   *     .build();
+   *   Shelf response = libraryServiceClient.createShelf(request);
+   * }
+   * 
+ * + * @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 Shelf createShelf(CreateShelfRequest request) { + return createShelfCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a shelf, and returns the new Shelf. + * RPC method comment may include special characters: <>&"`'{@literal @}. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   Shelf shelf = Shelf.newBuilder().build();
+   *   CreateShelfRequest request = CreateShelfRequest.newBuilder()
+   *     .setShelf(shelf)
+   *     .build();
+   *   ApiFuture<Shelf> future = libraryServiceClient.createShelfCallable().futureCall(request);
+   *   // Do something
+   *   Shelf response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable createShelfCallable() { + return stub.createShelfCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   Shelf response = libraryServiceClient.getShelf(name);
+   * }
+   * 
+ * + * @param name The name of the shelf to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf getShelf(ShelfName name) { + GetShelfRequest request = + GetShelfRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   Shelf response = libraryServiceClient.getShelf(name.toString());
+   * }
+   * 
+ * + * @param name The name of the shelf to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf getShelf(String name) { + GetShelfRequest request = + GetShelfRequest.newBuilder() + .setName(name) + .build(); + return getShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   SomeMessage message = SomeMessage.newBuilder().build();
+   *   Shelf response = libraryServiceClient.getShelf(name, message);
+   * }
+   * 
+ * + * @param name The name of the shelf to retrieve. + * @param message Field to verify that message-type query parameter gets flattened. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf getShelf(ShelfName name, SomeMessage message) { + GetShelfRequest request = + GetShelfRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setMessage(message) + .build(); + return getShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   SomeMessage message = SomeMessage.newBuilder().build();
+   *   Shelf response = libraryServiceClient.getShelf(name.toString(), message);
+   * }
+   * 
+ * + * @param name The name of the shelf to retrieve. + * @param message Field to verify that message-type query parameter gets flattened. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf getShelf(String name, SomeMessage message) { + GetShelfRequest request = + GetShelfRequest.newBuilder() + .setName(name) + .setMessage(message) + .build(); + return getShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   SomeMessage message = SomeMessage.newBuilder().build();
+   *   com.google.example.library.v1.StringBuilder stringBuilder = com.google.example.library.v1.StringBuilder.newBuilder().build();
+   *   Shelf response = libraryServiceClient.getShelf(name, message, stringBuilder);
+   * }
+   * 
+ * + * @param name The name of the shelf to retrieve. + * @param message Field to verify that message-type query parameter gets flattened. + * @param stringBuilder + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf getShelf(ShelfName name, SomeMessage message, com.google.example.library.v1.StringBuilder stringBuilder) { + GetShelfRequest request = + GetShelfRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setMessage(message) + .setStringBuilder(stringBuilder) + .build(); + return getShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   SomeMessage message = SomeMessage.newBuilder().build();
+   *   com.google.example.library.v1.StringBuilder stringBuilder = com.google.example.library.v1.StringBuilder.newBuilder().build();
+   *   Shelf response = libraryServiceClient.getShelf(name.toString(), message, stringBuilder);
+   * }
+   * 
+ * + * @param name The name of the shelf to retrieve. + * @param message Field to verify that message-type query parameter gets flattened. + * @param stringBuilder + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf getShelf(String name, SomeMessage message, com.google.example.library.v1.StringBuilder stringBuilder) { + GetShelfRequest request = + GetShelfRequest.newBuilder() + .setName(name) + .setMessage(message) + .setStringBuilder(stringBuilder) + .build(); + return getShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   String options = "";
+   *   GetShelfRequest request = GetShelfRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setOptions(options)
+   *     .build();
+   *   Shelf response = libraryServiceClient.getShelf(request);
+   * }
+   * 
+ * + * @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 Shelf getShelf(GetShelfRequest request) { + return getShelfCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   String options = "";
+   *   GetShelfRequest request = GetShelfRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setOptions(options)
+   *     .build();
+   *   ApiFuture<Shelf> future = libraryServiceClient.getShelfCallable().futureCall(request);
+   *   // Do something
+   *   Shelf response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getShelfCallable() { + return stub.getShelfCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists shelves. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *
+   *   ListShelvesResponse response = libraryServiceClient.listShelves();
+   * }
+   * 
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListShelvesResponse listShelves() { + ListShelvesRequest request = + ListShelvesRequest.newBuilder().build(); + return listShelves(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists shelves. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ListShelvesRequest request = ListShelvesRequest.newBuilder().build();
+   *   ListShelvesResponse response = libraryServiceClient.listShelves(request);
+   * }
+   * 
+ * + * @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 ListShelvesResponse listShelves(ListShelvesRequest request) { + return listShelvesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists shelves. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ListShelvesRequest request = ListShelvesRequest.newBuilder().build();
+   *   ApiFuture<ListShelvesResponse> future = libraryServiceClient.listShelvesCallable().futureCall(request);
+   *   // Do something
+   *   ListShelvesResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable listShelvesCallable() { + return stub.listShelvesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   libraryServiceClient.deleteShelf(name);
+   * }
+   * 
+ * + * @param name The name of the shelf to delete. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteShelf(ShelfName name) { + DeleteShelfRequest request = + DeleteShelfRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + deleteShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   libraryServiceClient.deleteShelf(name.toString());
+   * }
+   * 
+ * + * @param name The name of the shelf to delete. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteShelf(String name) { + DeleteShelfRequest request = + DeleteShelfRequest.newBuilder() + .setName(name) + .build(); + deleteShelf(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   DeleteShelfRequest request = DeleteShelfRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   libraryServiceClient.deleteShelf(request);
+   * }
+   * 
+ * + * @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 deleteShelf(DeleteShelfRequest request) { + deleteShelfCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   DeleteShelfRequest request = DeleteShelfRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = libraryServiceClient.deleteShelfCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteShelfCallable() { + return stub.deleteShelfCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Merges two shelves by adding all books from the shelf named + * `other_shelf_name` to shelf `name`, and deletes + * `other_shelf_name`. Returns the updated shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   ShelfName otherShelfName = ShelfName.of("[SHELF]");
+   *   Shelf response = libraryServiceClient.mergeShelves(name, otherShelfName);
+   * }
+   * 
+ * + * @param name The name of the shelf we're adding books to. + * @param otherShelfName The name of the shelf we're removing books from and deleting. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf mergeShelves(ShelfName name, ShelfName otherShelfName) { + MergeShelvesRequest request = + MergeShelvesRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setOtherShelfName(otherShelfName == null ? null : otherShelfName.toString()) + .build(); + return mergeShelves(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Merges two shelves by adding all books from the shelf named + * `other_shelf_name` to shelf `name`, and deletes + * `other_shelf_name`. Returns the updated shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   ShelfName otherShelfName = ShelfName.of("[SHELF]");
+   *   Shelf response = libraryServiceClient.mergeShelves(name.toString(), otherShelfName.toString());
+   * }
+   * 
+ * + * @param name The name of the shelf we're adding books to. + * @param otherShelfName The name of the shelf we're removing books from and deleting. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Shelf mergeShelves(String name, String otherShelfName) { + MergeShelvesRequest request = + MergeShelvesRequest.newBuilder() + .setName(name) + .setOtherShelfName(otherShelfName) + .build(); + return mergeShelves(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Merges two shelves by adding all books from the shelf named + * `other_shelf_name` to shelf `name`, and deletes + * `other_shelf_name`. Returns the updated shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   ShelfName otherShelfName = ShelfName.of("[SHELF]");
+   *   MergeShelvesRequest request = MergeShelvesRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setOtherShelfName(otherShelfName.toString())
+   *     .build();
+   *   Shelf response = libraryServiceClient.mergeShelves(request);
+   * }
+   * 
+ * + * @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 Shelf mergeShelves(MergeShelvesRequest request) { + return mergeShelvesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Merges two shelves by adding all books from the shelf named + * `other_shelf_name` to shelf `name`, and deletes + * `other_shelf_name`. Returns the updated shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   ShelfName otherShelfName = ShelfName.of("[SHELF]");
+   *   MergeShelvesRequest request = MergeShelvesRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setOtherShelfName(otherShelfName.toString())
+   *     .build();
+   *   ApiFuture<Shelf> future = libraryServiceClient.mergeShelvesCallable().futureCall(request);
+   *   // Do something
+   *   Shelf response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable mergeShelvesCallable() { + return stub.mergeShelvesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   Book book = Book.newBuilder().build();
+   *   Book response = libraryServiceClient.createBook(name, book);
+   * }
+   * 
+ * + * @param name The name of the shelf in which the book is created. + * @param book The book to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book createBook(ShelfName name, Book book) { + CreateBookRequest request = + CreateBookRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setBook(book) + .build(); + return createBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   Book book = Book.newBuilder().build();
+   *   Book response = libraryServiceClient.createBook(name.toString(), book);
+   * }
+   * 
+ * + * @param name The name of the shelf in which the book is created. + * @param book The book to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book createBook(String name, Book book) { + CreateBookRequest request = + CreateBookRequest.newBuilder() + .setName(name) + .setBook(book) + .build(); + return createBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   Book book = Book.newBuilder().build();
+   *   CreateBookRequest request = CreateBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setBook(book)
+   *     .build();
+   *   Book response = libraryServiceClient.createBook(request);
+   * }
+   * 
+ * + * @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 Book createBook(CreateBookRequest request) { + return createBookCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   Book book = Book.newBuilder().build();
+   *   CreateBookRequest request = CreateBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setBook(book)
+   *     .build();
+   *   ApiFuture<Book> future = libraryServiceClient.createBookCallable().futureCall(request);
+   *   // Do something
+   *   Book response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable createBookCallable() { + return stub.createBookCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a series of books. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   Shelf shelf = Shelf.newBuilder().build();
+   *   List<Book> books = new ArrayList<>();
+   *   int edition = 0;
+   *   SeriesUuid seriesUuid = SeriesUuid.newBuilder().build();
+   *   PublisherName publisher = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   PublishSeriesResponse response = libraryServiceClient.publishSeries(shelf, books, edition, seriesUuid, publisher);
+   * }
+   * 
+ * + * @param shelf The shelf in which the series is created. + * @param books The books to publish in the series. + * @param edition The edition of the series + * @param seriesUuid Uniquely identifies the series to the publishing house. + * @param publisher The publisher of the series. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PublishSeriesResponse publishSeries(Shelf shelf, List books, int edition, SeriesUuid seriesUuid, PublisherName publisher) { + PublishSeriesRequest request = + PublishSeriesRequest.newBuilder() + .setShelf(shelf) + .addAllBooks(books) + .setEdition(edition) + .setSeriesUuid(seriesUuid) + .setPublisher(publisher == null ? null : publisher.toString()) + .build(); + return publishSeries(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a series of books. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   Shelf shelf = Shelf.newBuilder().build();
+   *   List<Book> books = new ArrayList<>();
+   *   int edition = 0;
+   *   SeriesUuid seriesUuid = SeriesUuid.newBuilder().build();
+   *   PublisherName publisher = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   PublishSeriesResponse response = libraryServiceClient.publishSeries(shelf, books, edition, seriesUuid, publisher.toString());
+   * }
+   * 
+ * + * @param shelf The shelf in which the series is created. + * @param books The books to publish in the series. + * @param edition The edition of the series + * @param seriesUuid Uniquely identifies the series to the publishing house. + * @param publisher The publisher of the series. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PublishSeriesResponse publishSeries(Shelf shelf, List books, int edition, SeriesUuid seriesUuid, String publisher) { + PublishSeriesRequest request = + PublishSeriesRequest.newBuilder() + .setShelf(shelf) + .addAllBooks(books) + .setEdition(edition) + .setSeriesUuid(seriesUuid) + .setPublisher(publisher) + .build(); + return publishSeries(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a series of books. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   Shelf shelf = Shelf.newBuilder().build();
+   *   List<Book> books = new ArrayList<>();
+   *   SeriesUuid seriesUuid = SeriesUuid.newBuilder().build();
+   *   PublishSeriesRequest request = PublishSeriesRequest.newBuilder()
+   *     .setShelf(shelf)
+   *     .addAllBooks(books)
+   *     .setSeriesUuid(seriesUuid)
+   *     .build();
+   *   PublishSeriesResponse response = libraryServiceClient.publishSeries(request);
+   * }
+   * 
+ * + * @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 PublishSeriesResponse publishSeries(PublishSeriesRequest request) { + return publishSeriesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates a series of books. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   Shelf shelf = Shelf.newBuilder().build();
+   *   List<Book> books = new ArrayList<>();
+   *   SeriesUuid seriesUuid = SeriesUuid.newBuilder().build();
+   *   PublishSeriesRequest request = PublishSeriesRequest.newBuilder()
+   *     .setShelf(shelf)
+   *     .addAllBooks(books)
+   *     .setSeriesUuid(seriesUuid)
+   *     .build();
+   *   ApiFuture<PublishSeriesResponse> future = libraryServiceClient.publishSeriesCallable().futureCall(request);
+   *   // Do something
+   *   PublishSeriesResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable publishSeriesCallable() { + return stub.publishSeriesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an inventory. Tests singleton resources. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   PublisherName parent = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   Inventory inventory = Inventory.newBuilder().build();
+   *   ResourceName asset = ArchiveName.of("[ARCHIVE]");
+   *   ResourceName parentAsset = ArchiveName.of("[ARCHIVE]");
+   *   List<String> assets = new ArrayList<>();
+   *   Inventory response = libraryServiceClient.createInventory(parent, inventory, asset, parentAsset, assets);
+   * }
+   * 
+ * + * @param parent + * @param inventory + * @param asset + * @param parentAsset + * @param assets + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Inventory createInventory(PublisherName parent, Inventory inventory, ResourceName asset, ResourceName parentAsset, List assets) { + CreateInventoryRequest request = + CreateInventoryRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setInventory(inventory) + .setAsset(asset == null ? null : asset.toString()) + .setParentAsset(parentAsset == null ? null : parentAsset.toString()) + .addAllAssets(assets) + .build(); + return createInventory(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an inventory. Tests singleton resources. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   PublisherName parent = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   Inventory inventory = Inventory.newBuilder().build();
+   *   ResourceName asset = ArchiveName.of("[ARCHIVE]");
+   *   ResourceName parentAsset = ArchiveName.of("[ARCHIVE]");
+   *   List<String> assets = new ArrayList<>();
+   *   Inventory response = libraryServiceClient.createInventory(parent.toString(), inventory, asset.toString(), parentAsset.toString(), assets);
+   * }
+   * 
+ * + * @param parent + * @param inventory + * @param asset + * @param parentAsset + * @param assets + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Inventory createInventory(String parent, Inventory inventory, String asset, String parentAsset, List assets) { + CreateInventoryRequest request = + CreateInventoryRequest.newBuilder() + .setParent(parent) + .setInventory(inventory) + .setAsset(asset) + .setParentAsset(parentAsset) + .addAllAssets(assets) + .build(); + return createInventory(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an inventory. Tests singleton resources. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   PublisherName parent = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   ResourceName asset = ArchiveName.of("[ARCHIVE]");
+   *   ResourceName parentAsset = ArchiveName.of("[ARCHIVE]");
+   *   List<ResourceName> assets = new ArrayList<>();
+   *   CreateInventoryRequest request = CreateInventoryRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setAsset(asset.toString())
+   *     .setParentAsset(parentAsset.toString())
+   *     .addAllAssets(UntypedResourceName.toStringList(assets))
+   *     .build();
+   *   Inventory response = libraryServiceClient.createInventory(request);
+   * }
+   * 
+ * + * @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 Inventory createInventory(CreateInventoryRequest request) { + return createInventoryCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Creates an inventory. Tests singleton resources. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   PublisherName parent = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   ResourceName asset = ArchiveName.of("[ARCHIVE]");
+   *   ResourceName parentAsset = ArchiveName.of("[ARCHIVE]");
+   *   List<ResourceName> assets = new ArrayList<>();
+   *   CreateInventoryRequest request = CreateInventoryRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .setAsset(asset.toString())
+   *     .setParentAsset(parentAsset.toString())
+   *     .addAllAssets(UntypedResourceName.toStringList(assets))
+   *     .build();
+   *   ApiFuture<Inventory> future = libraryServiceClient.createInventoryCallable().futureCall(request);
+   *   // Do something
+   *   Inventory response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable createInventoryCallable() { + return stub.createInventoryCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book response = libraryServiceClient.getBook(name);
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book getBook(BookName name) { + GetBookRequest request = + GetBookRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book response = libraryServiceClient.getBook(name.toString());
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book getBook(String name) { + GetBookRequest request = + GetBookRequest.newBuilder() + .setName(name) + .build(); + return getBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookRequest request = GetBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   Book response = libraryServiceClient.getBook(request);
+   * }
+   * 
+ * + * @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 Book getBook(GetBookRequest request) { + return getBookCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookRequest request = GetBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Book> future = libraryServiceClient.getBookCallable().futureCall(request);
+   *   // Do something
+   *   Book response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getBookCallable() { + return stub.getBookCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists books in a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   String filter = "";
+   *   for (Book element : libraryServiceClient.listBooks(name, filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param name The name of the shelf whose books we'd like to list. + * @param filter To test python built-in wrapping. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBooksPagedResponse listBooks(ShelfName name, String filter) { + ListBooksRequest request = + ListBooksRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setFilter(filter) + .build(); + return listBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists books in a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   String filter = "";
+   *   for (Book element : libraryServiceClient.listBooks(name.toString(), filter).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param name The name of the shelf whose books we'd like to list. + * @param filter To test python built-in wrapping. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBooksPagedResponse listBooks(String name, String filter) { + ListBooksRequest request = + ListBooksRequest.newBuilder() + .setName(name) + .setFilter(filter) + .build(); + return listBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists books in a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   ListBooksRequest request = ListBooksRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   for (Book element : libraryServiceClient.listBooks(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @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 ListBooksPagedResponse listBooks(ListBooksRequest request) { + return listBooksPagedCallable() + .call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists books in a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   ListBooksRequest request = ListBooksRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<ListBooksPagedResponse> future = libraryServiceClient.listBooksPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (Book element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listBooksPagedCallable() { + return stub.listBooksPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists books in a shelf. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName name = ShelfName.of("[SHELF]");
+   *   ListBooksRequest request = ListBooksRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   while (true) {
+   *     ListBooksResponse response = libraryServiceClient.listBooksCallable().call(request);
+   *     for (Book element : response.getBooksList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listBooksCallable() { + return stub.listBooksCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   libraryServiceClient.deleteBook(name);
+   * }
+   * 
+ * + * @param name The name of the book to delete. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBook(BookName name) { + DeleteBookRequest request = + DeleteBookRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + deleteBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   libraryServiceClient.deleteBook(name.toString());
+   * }
+   * 
+ * + * @param name The name of the book to delete. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBook(String name) { + DeleteBookRequest request = + DeleteBookRequest.newBuilder() + .setName(name) + .build(); + deleteBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   DeleteBookRequest request = DeleteBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   libraryServiceClient.deleteBook(request);
+   * }
+   * 
+ * + * @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 deleteBook(DeleteBookRequest request) { + deleteBookCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   DeleteBookRequest request = DeleteBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = libraryServiceClient.deleteBookCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteBookCallable() { + return stub.deleteBookCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book book = Book.newBuilder().build();
+   *   Book response = libraryServiceClient.updateBook(name, book);
+   * }
+   * 
+ * + * @param name The name of the book to update. + * @param book The book to update with. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book updateBook(BookName name, Book book) { + UpdateBookRequest request = + UpdateBookRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setBook(book) + .build(); + return updateBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book book = Book.newBuilder().build();
+   *   Book response = libraryServiceClient.updateBook(name.toString(), book);
+   * }
+   * 
+ * + * @param name The name of the book to update. + * @param book The book to update with. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book updateBook(String name, Book book) { + UpdateBookRequest request = + UpdateBookRequest.newBuilder() + .setName(name) + .setBook(book) + .build(); + return updateBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String optionalFoo = "";
+   *   Book book = Book.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   com.google.example.library.v1.FieldMask physicalMask = com.google.example.library.v1.FieldMask.newBuilder().build();
+   *   Book response = libraryServiceClient.updateBook(name, optionalFoo, book, updateMask, physicalMask);
+   * }
+   * 
+ * + * @param name The name of the book to update. + * @param optionalFoo An optional foo. + * @param book The book to update with. + * @param updateMask A field mask to apply, rendered as an HTTP parameter. + * @param physicalMask To test Python import clash resolution. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book updateBook(BookName name, String optionalFoo, Book book, FieldMask updateMask, com.google.example.library.v1.FieldMask physicalMask) { + UpdateBookRequest request = + UpdateBookRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setOptionalFoo(optionalFoo) + .setBook(book) + .setUpdateMask(updateMask) + .setPhysicalMask(physicalMask) + .build(); + return updateBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String optionalFoo = "";
+   *   Book book = Book.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   com.google.example.library.v1.FieldMask physicalMask = com.google.example.library.v1.FieldMask.newBuilder().build();
+   *   Book response = libraryServiceClient.updateBook(name.toString(), optionalFoo, book, updateMask, physicalMask);
+   * }
+   * 
+ * + * @param name The name of the book to update. + * @param optionalFoo An optional foo. + * @param book The book to update with. + * @param updateMask A field mask to apply, rendered as an HTTP parameter. + * @param physicalMask To test Python import clash resolution. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book updateBook(String name, String optionalFoo, Book book, FieldMask updateMask, com.google.example.library.v1.FieldMask physicalMask) { + UpdateBookRequest request = + UpdateBookRequest.newBuilder() + .setName(name) + .setOptionalFoo(optionalFoo) + .setBook(book) + .setUpdateMask(updateMask) + .setPhysicalMask(physicalMask) + .build(); + return updateBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book book = Book.newBuilder().build();
+   *   UpdateBookRequest request = UpdateBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setBook(book)
+   *     .build();
+   *   Book response = libraryServiceClient.updateBook(request);
+   * }
+   * 
+ * + * @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 Book updateBook(UpdateBookRequest request) { + return updateBookCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book book = Book.newBuilder().build();
+   *   UpdateBookRequest request = UpdateBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setBook(book)
+   *     .build();
+   *   ApiFuture<Book> future = libraryServiceClient.updateBookCallable().futureCall(request);
+   *   // Do something
+   *   Book response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable updateBookCallable() { + return stub.updateBookCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Moves a book to another shelf, and returns the new book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   ShelfName otherShelfName = ShelfName.of("[SHELF]");
+   *   Book response = libraryServiceClient.moveBook(name, otherShelfName);
+   * }
+   * 
+ * + * @param name The name of the book to move. + * @param otherShelfName The name of the destination shelf. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book moveBook(BookName name, ShelfName otherShelfName) { + MoveBookRequest request = + MoveBookRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setOtherShelfName(otherShelfName == null ? null : otherShelfName.toString()) + .build(); + return moveBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Moves a book to another shelf, and returns the new book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   ShelfName otherShelfName = ShelfName.of("[SHELF]");
+   *   Book response = libraryServiceClient.moveBook(name.toString(), otherShelfName.toString());
+   * }
+   * 
+ * + * @param name The name of the book to move. + * @param otherShelfName The name of the destination shelf. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book moveBook(String name, String otherShelfName) { + MoveBookRequest request = + MoveBookRequest.newBuilder() + .setName(name) + .setOtherShelfName(otherShelfName) + .build(); + return moveBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Moves a book to another shelf, and returns the new book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   ShelfName otherShelfName = ShelfName.of("[SHELF]");
+   *   MoveBookRequest request = MoveBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setOtherShelfName(otherShelfName.toString())
+   *     .build();
+   *   Book response = libraryServiceClient.moveBook(request);
+   * }
+   * 
+ * + * @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 Book moveBook(MoveBookRequest request) { + return moveBookCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Moves a book to another shelf, and returns the new book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   ShelfName otherShelfName = ShelfName.of("[SHELF]");
+   *   MoveBookRequest request = MoveBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setOtherShelfName(otherShelfName.toString())
+   *     .build();
+   *   ApiFuture<Book> future = libraryServiceClient.moveBookCallable().futureCall(request);
+   *   // Do something
+   *   Book response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable moveBookCallable() { + return stub.moveBookCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists a primitive resource. To test go page streaming. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *
+   *   for (ResourceName element : libraryServiceClient.listStrings().iterateAllAsResourceName()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListStringsPagedResponse listStrings() { + ListStringsRequest request = + ListStringsRequest.newBuilder().build(); + return listStrings(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists a primitive resource. To test go page streaming. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ResourceName name = ArchiveName.of("[ARCHIVE]");
+   *   for (ResourceName element : libraryServiceClient.listStrings(name).iterateAllAsResourceName()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param name + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListStringsPagedResponse listStrings(ResourceName name) { + ListStringsRequest request = + ListStringsRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return listStrings(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists a primitive resource. To test go page streaming. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ResourceName name = ArchiveName.of("[ARCHIVE]");
+   *   for (ResourceName element : libraryServiceClient.listStrings(name.toString()).iterateAllAsResourceName()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param name + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListStringsPagedResponse listStrings(String name) { + ListStringsRequest request = + ListStringsRequest.newBuilder() + .setName(name) + .build(); + return listStrings(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists a primitive resource. To test go page streaming. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ListStringsRequest request = ListStringsRequest.newBuilder().build();
+   *   for (ResourceName element : libraryServiceClient.listStrings(request).iterateAllAsResourceName()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @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 ListStringsPagedResponse listStrings(ListStringsRequest request) { + return listStringsPagedCallable() + .call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists a primitive resource. To test go page streaming. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ListStringsRequest request = ListStringsRequest.newBuilder().build();
+   *   ApiFuture<ListStringsPagedResponse> future = libraryServiceClient.listStringsPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (ResourceName element : future.get().iterateAllAsResourceName()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listStringsPagedCallable() { + return stub.listStringsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Lists a primitive resource. To test go page streaming. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ListStringsRequest request = ListStringsRequest.newBuilder().build();
+   *   while (true) {
+   *     ListStringsResponse response = libraryServiceClient.listStringsCallable().call(request);
+   *     for (ResourceName element : UntypedResourceName.parseList(response.getStringsList())) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable listStringsCallable() { + return stub.listStringsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Adds comments to a book + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   List<Comment> comments = new ArrayList<>();
+   *   libraryServiceClient.addComments(name, comments);
+   * }
+   * 
+ * + * @param name + * @param comments + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void addComments(BookName name, List comments) { + AddCommentsRequest request = + AddCommentsRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .addAllComments(comments) + .build(); + addComments(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Adds comments to a book + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   List<Comment> comments = new ArrayList<>();
+   *   libraryServiceClient.addComments(name.toString(), comments);
+   * }
+   * 
+ * + * @param name + * @param comments + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void addComments(String name, List comments) { + AddCommentsRequest request = + AddCommentsRequest.newBuilder() + .setName(name) + .addAllComments(comments) + .build(); + addComments(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Adds comments to a book + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   List<Comment> comments = new ArrayList<>();
+   *   AddCommentsRequest request = AddCommentsRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .addAllComments(comments)
+   *     .build();
+   *   libraryServiceClient.addComments(request);
+   * }
+   * 
+ * + * @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 addComments(AddCommentsRequest request) { + addCommentsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Adds comments to a book + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   List<Comment> comments = new ArrayList<>();
+   *   AddCommentsRequest request = AddCommentsRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .addAllComments(comments)
+   *     .build();
+   *   ApiFuture<Void> future = libraryServiceClient.addCommentsCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable addCommentsCallable() { + return stub.addCommentsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book from an archive. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchivedBookName name = ArchivedBookName.of("[ARCHIVE]", "[BOOK]");
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   BookFromArchive response = libraryServiceClient.getBookFromArchive(name, parent);
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @param parent + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BookFromArchive getBookFromArchive(ArchivedBookName name, ProjectName parent) { + GetBookFromArchiveRequest request = + GetBookFromArchiveRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setParent(parent == null ? null : parent.toString()) + .build(); + return getBookFromArchive(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book from an archive. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchivedBookName name = ArchivedBookName.of("[ARCHIVE]", "[BOOK]");
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   BookFromArchive response = libraryServiceClient.getBookFromArchive(name.toString(), parent.toString());
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @param parent + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BookFromArchive getBookFromArchive(String name, String parent) { + GetBookFromArchiveRequest request = + GetBookFromArchiveRequest.newBuilder() + .setName(name) + .setParent(parent) + .build(); + return getBookFromArchive(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book from an archive. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchivedBookName name = ArchivedBookName.of("[ARCHIVE]", "[BOOK]");
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   GetBookFromArchiveRequest request = GetBookFromArchiveRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setParent(parent.toString())
+   *     .build();
+   *   BookFromArchive response = libraryServiceClient.getBookFromArchive(request);
+   * }
+   * 
+ * + * @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 BookFromArchive getBookFromArchive(GetBookFromArchiveRequest request) { + return getBookFromArchiveCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book from an archive. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchivedBookName name = ArchivedBookName.of("[ARCHIVE]", "[BOOK]");
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   GetBookFromArchiveRequest request = GetBookFromArchiveRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<BookFromArchive> future = libraryServiceClient.getBookFromArchiveCallable().futureCall(request);
+   *   // Do something
+   *   BookFromArchive response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getBookFromArchiveCallable() { + return stub.getBookFromArchiveCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book from a shelf or archive. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName altBookName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   LocationName place = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   FolderName folder = FolderName.of("[FOLDER]");
+   *   BookFromAnywhere response = libraryServiceClient.getBookFromAnywhere(name, altBookName, place, folder);
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @param altBookName An alternate book name, used to test restricting flattened field to a + * single resource name type in a oneof. + * @param place + * @param folder + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BookFromAnywhere getBookFromAnywhere(BookName name, BookName altBookName, LocationName place, FolderName folder) { + GetBookFromAnywhereRequest request = + GetBookFromAnywhereRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setAltBookName(altBookName == null ? null : altBookName.toString()) + .setPlace(place == null ? null : place.toString()) + .setFolder(folder == null ? null : folder.toString()) + .build(); + return getBookFromAnywhere(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book from a shelf or archive. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName altBookName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   LocationName place = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   FolderName folder = FolderName.of("[FOLDER]");
+   *   BookFromAnywhere response = libraryServiceClient.getBookFromAnywhere(name.toString(), altBookName.toString(), place.toString(), folder.toString());
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @param altBookName An alternate book name, used to test restricting flattened field to a + * single resource name type in a oneof. + * @param place + * @param folder + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BookFromAnywhere getBookFromAnywhere(String name, String altBookName, String place, String folder) { + GetBookFromAnywhereRequest request = + GetBookFromAnywhereRequest.newBuilder() + .setName(name) + .setAltBookName(altBookName) + .setPlace(place) + .setFolder(folder) + .build(); + return getBookFromAnywhere(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book from a shelf or archive. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName altBookName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   LocationName place = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   FolderName folder = FolderName.of("[FOLDER]");
+   *   GetBookFromAnywhereRequest request = GetBookFromAnywhereRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setAltBookName(altBookName.toString())
+   *     .setPlace(place.toString())
+   *     .setFolder(folder.toString())
+   *     .build();
+   *   BookFromAnywhere response = libraryServiceClient.getBookFromAnywhere(request);
+   * }
+   * 
+ * + * @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 BookFromAnywhere getBookFromAnywhere(GetBookFromAnywhereRequest request) { + return getBookFromAnywhereCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets a book from a shelf or archive. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName altBookName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   LocationName place = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   FolderName folder = FolderName.of("[FOLDER]");
+   *   GetBookFromAnywhereRequest request = GetBookFromAnywhereRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setAltBookName(altBookName.toString())
+   *     .setPlace(place.toString())
+   *     .setFolder(folder.toString())
+   *     .build();
+   *   ApiFuture<BookFromAnywhere> future = libraryServiceClient.getBookFromAnywhereCallable().futureCall(request);
+   *   // Do something
+   *   BookFromAnywhere response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getBookFromAnywhereCallable() { + return stub.getBookFromAnywhereCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test proper OneOf-Any resource name mapping + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookFromAnywhere response = libraryServiceClient.getBookFromAbsolutelyAnywhere(name);
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BookFromAnywhere getBookFromAbsolutelyAnywhere(BookName name) { + GetBookFromAbsolutelyAnywhereRequest request = + GetBookFromAbsolutelyAnywhereRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getBookFromAbsolutelyAnywhere(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test proper OneOf-Any resource name mapping + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookFromAnywhere response = libraryServiceClient.getBookFromAbsolutelyAnywhere(name.toString());
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BookFromAnywhere getBookFromAbsolutelyAnywhere(String name) { + GetBookFromAbsolutelyAnywhereRequest request = + GetBookFromAbsolutelyAnywhereRequest.newBuilder() + .setName(name) + .build(); + return getBookFromAbsolutelyAnywhere(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test proper OneOf-Any resource name mapping + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookFromAbsolutelyAnywhereRequest request = GetBookFromAbsolutelyAnywhereRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   BookFromAnywhere response = libraryServiceClient.getBookFromAbsolutelyAnywhere(request);
+   * }
+   * 
+ * + * @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 BookFromAnywhere getBookFromAbsolutelyAnywhere(GetBookFromAbsolutelyAnywhereRequest request) { + return getBookFromAbsolutelyAnywhereCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test proper OneOf-Any resource name mapping + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookFromAbsolutelyAnywhereRequest request = GetBookFromAbsolutelyAnywhereRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<BookFromAnywhere> future = libraryServiceClient.getBookFromAbsolutelyAnywhereCallable().futureCall(request);
+   *   // Do something
+   *   BookFromAnywhere response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getBookFromAbsolutelyAnywhereCallable() { + return stub.getBookFromAbsolutelyAnywhereCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the index of a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String indexName = "";
+   *   Map<String, String> indexMap = new HashMap<>();
+   *   libraryServiceClient.updateBookIndex(name, indexName, indexMap);
+   * }
+   * 
+ * + * @param name The name of the book to update. + * @param indexName The name of the index for the book + * @param indexMap The index to update the book with + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void updateBookIndex(BookName name, String indexName, Map indexMap) { + UpdateBookIndexRequest request = + UpdateBookIndexRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .setIndexName(indexName) + .putAllIndexMap(indexMap) + .build(); + updateBookIndex(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the index of a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String indexName = "";
+   *   Map<String, String> indexMap = new HashMap<>();
+   *   libraryServiceClient.updateBookIndex(name.toString(), indexName, indexMap);
+   * }
+   * 
+ * + * @param name The name of the book to update. + * @param indexName The name of the index for the book + * @param indexMap The index to update the book with + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void updateBookIndex(String name, String indexName, Map indexMap) { + UpdateBookIndexRequest request = + UpdateBookIndexRequest.newBuilder() + .setName(name) + .setIndexName(indexName) + .putAllIndexMap(indexMap) + .build(); + updateBookIndex(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the index of a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String indexName = "";
+   *   Map<String, String> indexMap = new HashMap<>();
+   *   UpdateBookIndexRequest request = UpdateBookIndexRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setIndexName(indexName)
+   *     .putAllIndexMap(indexMap)
+   *     .build();
+   *   libraryServiceClient.updateBookIndex(request);
+   * }
+   * 
+ * + * @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 updateBookIndex(UpdateBookIndexRequest request) { + updateBookIndexCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Updates the index of a book. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String indexName = "";
+   *   Map<String, String> indexMap = new HashMap<>();
+   *   UpdateBookIndexRequest request = UpdateBookIndexRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .setIndexName(indexName)
+   *     .putAllIndexMap(indexMap)
+   *     .build();
+   *   ApiFuture<Void> future = libraryServiceClient.updateBookIndexCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable updateBookIndexCallable() { + return stub.updateBookIndexCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   List<String> names = new ArrayList<>();
+   *   List<String> formattedShelves = new ArrayList<>();
+   *   for (BookName element : libraryServiceClient.findRelatedBooks(names, formattedShelves).iterateAllAsBookName()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @param names + * @param shelves + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final FindRelatedBooksPagedResponse findRelatedBooks(List names, List shelves) { + FindRelatedBooksRequest request = + FindRelatedBooksRequest.newBuilder() + .addAllNames(names) + .addAllShelves(shelves) + .build(); + return findRelatedBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   List<BookName> names = new ArrayList<>();
+   *   List<ShelfName> shelves = new ArrayList<>();
+   *   FindRelatedBooksRequest request = FindRelatedBooksRequest.newBuilder()
+   *     .addAllNames(BookName.toStringList(names))
+   *     .addAllShelves(ShelfName.toStringList(shelves))
+   *     .build();
+   *   for (BookName element : libraryServiceClient.findRelatedBooks(request).iterateAllAsBookName()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ * + * @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 FindRelatedBooksPagedResponse findRelatedBooks(FindRelatedBooksRequest request) { + return findRelatedBooksPagedCallable() + .call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   List<BookName> names = new ArrayList<>();
+   *   List<ShelfName> shelves = new ArrayList<>();
+   *   FindRelatedBooksRequest request = FindRelatedBooksRequest.newBuilder()
+   *     .addAllNames(BookName.toStringList(names))
+   *     .addAllShelves(ShelfName.toStringList(shelves))
+   *     .build();
+   *   ApiFuture<FindRelatedBooksPagedResponse> future = libraryServiceClient.findRelatedBooksPagedCallable().futureCall(request);
+   *   // Do something
+   *   for (BookName element : future.get().iterateAllAsBookName()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable findRelatedBooksPagedCallable() { + return stub.findRelatedBooksPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   List<BookName> names = new ArrayList<>();
+   *   List<ShelfName> shelves = new ArrayList<>();
+   *   FindRelatedBooksRequest request = FindRelatedBooksRequest.newBuilder()
+   *     .addAllNames(BookName.toStringList(names))
+   *     .addAllShelves(ShelfName.toStringList(shelves))
+   *     .build();
+   *   while (true) {
+   *     FindRelatedBooksResponse response = libraryServiceClient.findRelatedBooksCallable().call(request);
+   *     for (BookName element : BookName.parseList(response.getNamesList())) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * 
+ */ + public final UnaryCallable findRelatedBooksCallable() { + return stub.findRelatedBooksCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Adds a tag to the book. This RPC is a mixin. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ResourceName resource = ArchiveName.of("[ARCHIVE]");
+   *   String tag = "";
+   *   AddTagResponse response = libraryServiceClient.addTag(resource, tag);
+   * }
+   * 
+ * + * @param resource REQUIRED: The resource which the tag is being added to. + * In the form "shelves/{shelf_id}/books/{book_id}". + * @param tag REQUIRED: The tag to add. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final AddTagResponse addTag(ResourceName resource, String tag) { + AddTagRequest request = + AddTagRequest.newBuilder() + .setResource(resource == null ? null : resource.toString()) + .setTag(tag) + .build(); + return addTag(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Adds a tag to the book. This RPC is a mixin. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ResourceName resource = ArchiveName.of("[ARCHIVE]");
+   *   String tag = "";
+   *   AddTagResponse response = libraryServiceClient.addTag(resource.toString(), tag);
+   * }
+   * 
+ * + * @param resource REQUIRED: The resource which the tag is being added to. + * In the form "shelves/{shelf_id}/books/{book_id}". + * @param tag REQUIRED: The tag to add. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final AddTagResponse addTag(String resource, String tag) { + AddTagRequest request = + AddTagRequest.newBuilder() + .setResource(resource) + .setTag(tag) + .build(); + return addTag(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Adds a tag to the book. This RPC is a mixin. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ResourceName resource = ArchiveName.of("[ARCHIVE]");
+   *   String tag = "";
+   *   AddTagRequest request = AddTagRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .setTag(tag)
+   *     .build();
+   *   AddTagResponse response = libraryServiceClient.addTag(request);
+   * }
+   * 
+ * + * @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 AddTagResponse addTag(AddTagRequest request) { + return addTagCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Adds a tag to the book. This RPC is a mixin. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ResourceName resource = ArchiveName.of("[ARCHIVE]");
+   *   String tag = "";
+   *   AddTagRequest request = AddTagRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .setTag(tag)
+   *     .build();
+   *   ApiFuture<AddTagResponse> future = libraryServiceClient.addTagCallable().futureCall(request);
+   *   // Do something
+   *   AddTagResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable addTagCallable() { + return stub.addTagCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book response = libraryServiceClient.getBigBookAsync(name).get();
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture getBigBookAsync(BookName name) { + GetBookRequest request = + GetBookRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getBigBookAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book response = libraryServiceClient.getBigBookAsync(name.toString()).get();
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture getBigBookAsync(String name) { + GetBookRequest request = + GetBookRequest.newBuilder() + .setName(name) + .build(); + return getBigBookAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookRequest request = GetBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   Book response = libraryServiceClient.getBigBookAsync(request).get();
+   * }
+   * 
+ * + * @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 + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture getBigBookAsync(GetBookRequest request) { + return getBigBookOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookRequest request = GetBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   OperationFuture<Book, GetBigBookMetadata> future = libraryServiceClient.getBigBookOperationCallable().futureCall(request);
+   *   // Do something
+   *   Book response = future.get();
+   * }
+   * 
+ */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable getBigBookOperationCallable() { + return stub.getBigBookOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookRequest request = GetBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = libraryServiceClient.getBigBookCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getBigBookCallable() { + return stub.getBigBookCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations with empty return type. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   libraryServiceClient.getBigNothingAsync(name).get();
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture getBigNothingAsync(BookName name) { + GetBookRequest request = + GetBookRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getBigNothingAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations with empty return type. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   libraryServiceClient.getBigNothingAsync(name.toString()).get();
+   * }
+   * 
+ * + * @param name The name of the book to retrieve. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture getBigNothingAsync(String name) { + GetBookRequest request = + GetBookRequest.newBuilder() + .setName(name) + .build(); + return getBigNothingAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations with empty return type. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookRequest request = GetBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   libraryServiceClient.getBigNothingAsync(request).get();
+   * }
+   * 
+ * + * @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 + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture getBigNothingAsync(GetBookRequest request) { + return getBigNothingOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations with empty return type. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookRequest request = GetBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   OperationFuture<Empty, GetBigBookMetadata> future = libraryServiceClient.getBigNothingOperationCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable getBigNothingOperationCallable() { + return stub.getBigNothingOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test long-running operations with empty return type. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   GetBookRequest request = GetBookRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Operation> future = libraryServiceClient.getBigNothingCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getBigNothingCallable() { + return stub.getBigNothingCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveName destination = ArchiveName.of("[ARCHIVE]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ArchiveName source, ArchiveName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   InventoryName destination = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ArchiveName source, InventoryName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   ShelfName destination = ShelfName.of("[SHELF]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ArchiveName source, ShelfName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   ProjectName destination = ProjectName.of("[PROJECT]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ArchiveName source, ProjectName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   InventoryName source = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   ArchiveName destination = ArchiveName.of("[ARCHIVE]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(InventoryName source, ArchiveName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   InventoryName source = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   InventoryName destination = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(InventoryName source, InventoryName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   InventoryName source = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   ShelfName destination = ShelfName.of("[SHELF]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(InventoryName source, ShelfName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   InventoryName source = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   ProjectName destination = ProjectName.of("[PROJECT]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(InventoryName source, ProjectName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName source = ShelfName.of("[SHELF]");
+   *   ArchiveName destination = ArchiveName.of("[ARCHIVE]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ShelfName source, ArchiveName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName source = ShelfName.of("[SHELF]");
+   *   InventoryName destination = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ShelfName source, InventoryName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName source = ShelfName.of("[SHELF]");
+   *   ShelfName destination = ShelfName.of("[SHELF]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ShelfName source, ShelfName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName source = ShelfName.of("[SHELF]");
+   *   ProjectName destination = ProjectName.of("[PROJECT]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ShelfName source, ProjectName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ProjectName source = ProjectName.of("[PROJECT]");
+   *   ArchiveName destination = ArchiveName.of("[ARCHIVE]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ProjectName source, ArchiveName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ProjectName source = ProjectName.of("[PROJECT]");
+   *   InventoryName destination = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ProjectName source, InventoryName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ProjectName source = ProjectName.of("[PROJECT]");
+   *   ShelfName destination = ShelfName.of("[SHELF]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ProjectName source, ShelfName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ProjectName source = ProjectName.of("[PROJECT]");
+   *   ProjectName destination = ProjectName.of("[PROJECT]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source, destination, formattedPublishers, project);
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(ProjectName source, ProjectName destination, List publishers, ProjectName project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setDestination(destination == null ? null : destination.toString()) + .addAllPublishers(publishers) + .setProject(project == null ? null : project.toString()) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveName destination = ArchiveName.of("[ARCHIVE]");
+   *   List<String> formattedPublishers = new ArrayList<>();
+   *   ProjectName project = ProjectName.of("[PROJECT]");
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(source.toString(), destination.toString(), formattedPublishers, project.toString());
+   * }
+   * 
+ * + * @param source + * @param destination + * @param publishers + * @param project + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final MoveBooksResponse moveBooks(String source, String destination, List publishers, String project) { + MoveBooksRequest request = + MoveBooksRequest.newBuilder() + .setSource(source) + .setDestination(destination) + .addAllPublishers(publishers) + .setProject(project) + .build(); + return moveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   MoveBooksRequest request = MoveBooksRequest.newBuilder().build();
+   *   MoveBooksResponse response = libraryServiceClient.moveBooks(request);
+   * }
+   * 
+ * + * @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 MoveBooksResponse moveBooks(MoveBooksRequest request) { + return moveBooksCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   MoveBooksRequest request = MoveBooksRequest.newBuilder().build();
+   *   ApiFuture<MoveBooksResponse> future = libraryServiceClient.moveBooksCallable().futureCall(request);
+   *   // Do something
+   *   MoveBooksResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable moveBooksCallable() { + return stub.moveBooksCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.archiveBooks(source, archive);
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ArchiveBooksResponse archiveBooks(ArchiveName source, ArchiveName archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setArchive(archive == null ? null : archive.toString()) + .build(); + return archiveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   InventoryName source = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.archiveBooks(source, archive);
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ArchiveBooksResponse archiveBooks(InventoryName source, ArchiveName archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setArchive(archive == null ? null : archive.toString()) + .build(); + return archiveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName source = ShelfName.of("[SHELF]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.archiveBooks(source, archive);
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ArchiveBooksResponse archiveBooks(ShelfName source, ArchiveName archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setArchive(archive == null ? null : archive.toString()) + .build(); + return archiveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ProjectName source = ProjectName.of("[PROJECT]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.archiveBooks(source, archive);
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ArchiveBooksResponse archiveBooks(ProjectName source, ArchiveName archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setArchive(archive == null ? null : archive.toString()) + .build(); + return archiveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.archiveBooks(source.toString(), archive.toString());
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ArchiveBooksResponse archiveBooks(String source, String archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source) + .setArchive(archive) + .build(); + return archiveBooks(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveBooksRequest request = ArchiveBooksRequest.newBuilder().build();
+   *   ArchiveBooksResponse response = libraryServiceClient.archiveBooks(request);
+   * }
+   * 
+ * + * @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 ArchiveBooksResponse archiveBooks(ArchiveBooksRequest request) { + return archiveBooksCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveBooksRequest request = ArchiveBooksRequest.newBuilder().build();
+   *   ApiFuture<ArchiveBooksResponse> future = libraryServiceClient.archiveBooksCallable().futureCall(request);
+   *   // Do something
+   *   ArchiveBooksResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable archiveBooksCallable() { + return stub.archiveBooksCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.longRunningArchiveBooksAsync(source, archive).get();
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture longRunningArchiveBooksAsync(ArchiveName source, ArchiveName archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setArchive(archive == null ? null : archive.toString()) + .build(); + return longRunningArchiveBooksAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   InventoryName source = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.longRunningArchiveBooksAsync(source, archive).get();
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture longRunningArchiveBooksAsync(InventoryName source, ArchiveName archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setArchive(archive == null ? null : archive.toString()) + .build(); + return longRunningArchiveBooksAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ShelfName source = ShelfName.of("[SHELF]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.longRunningArchiveBooksAsync(source, archive).get();
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture longRunningArchiveBooksAsync(ShelfName source, ArchiveName archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setArchive(archive == null ? null : archive.toString()) + .build(); + return longRunningArchiveBooksAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ProjectName source = ProjectName.of("[PROJECT]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.longRunningArchiveBooksAsync(source, archive).get();
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture longRunningArchiveBooksAsync(ProjectName source, ArchiveName archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source == null ? null : source.toString()) + .setArchive(archive == null ? null : archive.toString()) + .build(); + return longRunningArchiveBooksAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveName source = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveName archive = ArchiveName.of("[ARCHIVE]");
+   *   ArchiveBooksResponse response = libraryServiceClient.longRunningArchiveBooksAsync(source.toString(), archive.toString()).get();
+   * }
+   * 
+ * + * @param source + * @param archive + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture longRunningArchiveBooksAsync(String source, String archive) { + ArchiveBooksRequest request = + ArchiveBooksRequest.newBuilder() + .setSource(source) + .setArchive(archive) + .build(); + return longRunningArchiveBooksAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveBooksRequest request = ArchiveBooksRequest.newBuilder().build();
+   *   ArchiveBooksResponse response = libraryServiceClient.longRunningArchiveBooksAsync(request).get();
+   * }
+   * 
+ * + * @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 + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public final OperationFuture longRunningArchiveBooksAsync(ArchiveBooksRequest request) { + return longRunningArchiveBooksOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveBooksRequest request = ArchiveBooksRequest.newBuilder().build();
+   *   OperationFuture<ArchiveBooksResponse, ArchiveBooksMetadata> future = libraryServiceClient.longRunningArchiveBooksOperationCallable().futureCall(request);
+   *   // Do something
+   *   ArchiveBooksResponse response = future.get();
+   * }
+   * 
+ */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public final OperationCallable longRunningArchiveBooksOperationCallable() { + return stub.longRunningArchiveBooksOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ArchiveBooksRequest request = ArchiveBooksRequest.newBuilder().build();
+   *   ApiFuture<Operation> future = libraryServiceClient.longRunningArchiveBooksCallable().futureCall(request);
+   *   // Do something
+   *   Operation response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable longRunningArchiveBooksCallable() { + return stub.longRunningArchiveBooksCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test using resource messages as request objects. Only used by PubSub (CreateSubscription) for historical reasons. + * New APIs should always create a separate message for a request. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String author = "";
+   *   String title = "";
+   *   Book.Rating rating = Book.Rating.GOOD;
+   *   libraryServiceClient.saveBook(name, author, title, rating);
+   * }
+   * 
+ * + * @param name The resource name of the book. + * Book names have the form `bookShelves/{shelf_id}/books/{book_id}`. + * Message field comment may include special characters: <>&"`'{@literal @}. + * @param author The name of the book author. + * @param title The title of the book. + * @param rating For testing enums. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void saveBook(BookName name, String author, String title, Book.Rating rating) { + Book request = + Book.newBuilder() + .setName(name == null ? null : name.toString()) + .setAuthor(author) + .setTitle(title) + .setRating(rating) + .build(); + saveBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test using resource messages as request objects. Only used by PubSub (CreateSubscription) for historical reasons. + * New APIs should always create a separate message for a request. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String author = "";
+   *   String title = "";
+   *   Book.Rating rating = Book.Rating.GOOD;
+   *   libraryServiceClient.saveBook(name.toString(), author, title, rating);
+   * }
+   * 
+ * + * @param name The resource name of the book. + * Book names have the form `bookShelves/{shelf_id}/books/{book_id}`. + * Message field comment may include special characters: <>&"`'{@literal @}. + * @param author The name of the book author. + * @param title The title of the book. + * @param rating For testing enums. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void saveBook(String name, String author, String title, Book.Rating rating) { + Book request = + Book.newBuilder() + .setName(name) + .setAuthor(author) + .setTitle(title) + .setRating(rating) + .build(); + saveBook(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test using resource messages as request objects. Only used by PubSub (CreateSubscription) for historical reasons. + * New APIs should always create a separate message for a request. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book request = Book.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   libraryServiceClient.saveBook(request);
+   * }
+   * 
+ * + * @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 saveBook(Book request) { + saveBookCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test using resource messages as request objects. Only used by PubSub (CreateSubscription) for historical reasons. + * New APIs should always create a separate message for a request. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   Book request = Book.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = libraryServiceClient.saveBookCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable saveBookCallable() { + return stub.saveBookCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test optional flattening parameters of all types + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *
+   *   TestOptionalRequiredFlatteningParamsResponse response = libraryServiceClient.testOptionalRequiredFlatteningParams();
+   * }
+   * 
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final TestOptionalRequiredFlatteningParamsResponse testOptionalRequiredFlatteningParams() { + TestOptionalRequiredFlatteningParamsRequest request = + TestOptionalRequiredFlatteningParamsRequest.newBuilder().build(); + return testOptionalRequiredFlatteningParams(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test optional flattening parameters of all types + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   int requiredSingularInt32 = 0;
+   *   long requiredSingularInt64 = 0L;
+   *   float requiredSingularFloat = 0.0F;
+   *   double requiredSingularDouble = 0.0;
+   *   boolean requiredSingularBool = false;
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerEnum requiredSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO;
+   *   String requiredSingularString = "";
+   *   ByteString requiredSingularBytes = ByteString.copyFromUtf8("");
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerMessage requiredSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build();
+   *   BookName requiredSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName requiredSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String requiredSingularResourceNameCommon = "";
+   *   int requiredSingularFixed32 = 0;
+   *   long requiredSingularFixed64 = 0L;
+   *   List<Integer> requiredRepeatedInt32 = new ArrayList<>();
+   *   List<Long> requiredRepeatedInt64 = new ArrayList<>();
+   *   List<Float> requiredRepeatedFloat = new ArrayList<>();
+   *   List<Double> requiredRepeatedDouble = new ArrayList<>();
+   *   List<Boolean> requiredRepeatedBool = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerEnum> requiredRepeatedEnum = new ArrayList<>();
+   *   List<String> requiredRepeatedString = new ArrayList<>();
+   *   List<ByteString> requiredRepeatedBytes = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerMessage> requiredRepeatedMessage = new ArrayList<>();
+   *   List<String> requiredRepeatedResourceName = new ArrayList<>();
+   *   List<String> requiredRepeatedResourceNameOneof = new ArrayList<>();
+   *   List<String> requiredRepeatedResourceNameCommon = new ArrayList<>();
+   *   List<Integer> requiredRepeatedFixed32 = new ArrayList<>();
+   *   List<Long> requiredRepeatedFixed64 = new ArrayList<>();
+   *   Map<Integer, String> requiredMap = new HashMap<>();
+   *   Any requiredAnyValue = Any.newBuilder().build();
+   *   Struct requiredStructValue = Struct.newBuilder().build();
+   *   Value requiredValueValue = Value.newBuilder().build();
+   *   ListValue requiredListValueValue = ListValue.newBuilder().build();
+   *   Timestamp requiredTimeValue = Timestamp.newBuilder().build();
+   *   Duration requiredDurationValue = Duration.newBuilder().build();
+   *   FieldMask requiredFieldMaskValue = FieldMask.newBuilder().build();
+   *   Int32Value requiredInt32Value = Int32Value.newBuilder().build();
+   *   UInt32Value requiredUint32Value = UInt32Value.newBuilder().build();
+   *   Int64Value requiredInt64Value = Int64Value.newBuilder().build();
+   *   UInt64Value requiredUint64Value = UInt64Value.newBuilder().build();
+   *   FloatValue requiredFloatValue = FloatValue.newBuilder().build();
+   *   DoubleValue requiredDoubleValue = DoubleValue.newBuilder().build();
+   *   StringValue requiredStringValue = StringValue.newBuilder().build();
+   *   BoolValue requiredBoolValue = BoolValue.newBuilder().build();
+   *   BytesValue requiredBytesValue = BytesValue.newBuilder().build();
+   *   List<Any> requiredRepeatedAnyValue = new ArrayList<>();
+   *   List<Struct> requiredRepeatedStructValue = new ArrayList<>();
+   *   List<Value> requiredRepeatedValueValue = new ArrayList<>();
+   *   List<ListValue> requiredRepeatedListValueValue = new ArrayList<>();
+   *   List<Timestamp> requiredRepeatedTimeValue = new ArrayList<>();
+   *   List<Duration> requiredRepeatedDurationValue = new ArrayList<>();
+   *   List<FieldMask> requiredRepeatedFieldMaskValue = new ArrayList<>();
+   *   List<Int32Value> requiredRepeatedInt32Value = new ArrayList<>();
+   *   List<UInt32Value> requiredRepeatedUint32Value = new ArrayList<>();
+   *   List<Int64Value> requiredRepeatedInt64Value = new ArrayList<>();
+   *   List<UInt64Value> requiredRepeatedUint64Value = new ArrayList<>();
+   *   List<FloatValue> requiredRepeatedFloatValue = new ArrayList<>();
+   *   List<DoubleValue> requiredRepeatedDoubleValue = new ArrayList<>();
+   *   List<StringValue> requiredRepeatedStringValue = new ArrayList<>();
+   *   List<BoolValue> requiredRepeatedBoolValue = new ArrayList<>();
+   *   List<BytesValue> requiredRepeatedBytesValue = new ArrayList<>();
+   *   int optionalSingularInt32 = 0;
+   *   long optionalSingularInt64 = 0L;
+   *   float optionalSingularFloat = 0.0F;
+   *   double optionalSingularDouble = 0.0;
+   *   boolean optionalSingularBool = false;
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerEnum optionalSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO;
+   *   String optionalSingularString = "";
+   *   ByteString optionalSingularBytes = ByteString.copyFromUtf8("");
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerMessage optionalSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build();
+   *   BookName optionalSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName optionalSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String optionalSingularResourceNameCommon = "";
+   *   int optionalSingularFixed32 = 0;
+   *   long optionalSingularFixed64 = 0L;
+   *   List<Integer> optionalRepeatedInt32 = new ArrayList<>();
+   *   List<Long> optionalRepeatedInt64 = new ArrayList<>();
+   *   List<Float> optionalRepeatedFloat = new ArrayList<>();
+   *   List<Double> optionalRepeatedDouble = new ArrayList<>();
+   *   List<Boolean> optionalRepeatedBool = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerEnum> optionalRepeatedEnum = new ArrayList<>();
+   *   List<String> optionalRepeatedString = new ArrayList<>();
+   *   List<ByteString> optionalRepeatedBytes = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerMessage> optionalRepeatedMessage = new ArrayList<>();
+   *   List<String> optionalRepeatedResourceName = new ArrayList<>();
+   *   List<String> optionalRepeatedResourceNameOneof = new ArrayList<>();
+   *   List<String> optionalRepeatedResourceNameCommon = new ArrayList<>();
+   *   List<Integer> optionalRepeatedFixed32 = new ArrayList<>();
+   *   List<Long> optionalRepeatedFixed64 = new ArrayList<>();
+   *   Map<Integer, String> optionalMap = new HashMap<>();
+   *   Any anyValue = Any.newBuilder().build();
+   *   Struct structValue = Struct.newBuilder().build();
+   *   Value valueValue = Value.newBuilder().build();
+   *   ListValue listValueValue = ListValue.newBuilder().build();
+   *   Timestamp timeValue = Timestamp.newBuilder().build();
+   *   Duration durationValue = Duration.newBuilder().build();
+   *   FieldMask fieldMaskValue = FieldMask.newBuilder().build();
+   *   Int32Value int32Value = Int32Value.newBuilder().build();
+   *   UInt32Value uint32Value = UInt32Value.newBuilder().build();
+   *   Int64Value int64Value = Int64Value.newBuilder().build();
+   *   UInt64Value uint64Value = UInt64Value.newBuilder().build();
+   *   FloatValue floatValue = FloatValue.newBuilder().build();
+   *   DoubleValue doubleValue = DoubleValue.newBuilder().build();
+   *   StringValue stringValue = StringValue.newBuilder().build();
+   *   BoolValue boolValue = BoolValue.newBuilder().build();
+   *   BytesValue bytesValue = BytesValue.newBuilder().build();
+   *   List<Any> repeatedAnyValue = new ArrayList<>();
+   *   List<Struct> repeatedStructValue = new ArrayList<>();
+   *   List<Value> repeatedValueValue = new ArrayList<>();
+   *   List<ListValue> repeatedListValueValue = new ArrayList<>();
+   *   List<Timestamp> repeatedTimeValue = new ArrayList<>();
+   *   List<Duration> repeatedDurationValue = new ArrayList<>();
+   *   List<FieldMask> repeatedFieldMaskValue = new ArrayList<>();
+   *   List<Int32Value> repeatedInt32Value = new ArrayList<>();
+   *   List<UInt32Value> repeatedUint32Value = new ArrayList<>();
+   *   List<Int64Value> repeatedInt64Value = new ArrayList<>();
+   *   List<UInt64Value> repeatedUint64Value = new ArrayList<>();
+   *   List<FloatValue> repeatedFloatValue = new ArrayList<>();
+   *   List<DoubleValue> repeatedDoubleValue = new ArrayList<>();
+   *   List<StringValue> repeatedStringValue = new ArrayList<>();
+   *   List<BoolValue> repeatedBoolValue = new ArrayList<>();
+   *   List<BytesValue> repeatedBytesValue = new ArrayList<>();
+   *   TestOptionalRequiredFlatteningParamsResponse response = libraryServiceClient.testOptionalRequiredFlatteningParams(requiredSingularInt32, requiredSingularInt64, requiredSingularFloat, requiredSingularDouble, requiredSingularBool, requiredSingularEnum, requiredSingularString, requiredSingularBytes, requiredSingularMessage, requiredSingularResourceName, requiredSingularResourceNameOneof, requiredSingularResourceNameCommon, requiredSingularFixed32, requiredSingularFixed64, requiredRepeatedInt32, requiredRepeatedInt64, requiredRepeatedFloat, requiredRepeatedDouble, requiredRepeatedBool, requiredRepeatedEnum, requiredRepeatedString, requiredRepeatedBytes, requiredRepeatedMessage, requiredRepeatedResourceName, requiredRepeatedResourceNameOneof, requiredRepeatedResourceNameCommon, requiredRepeatedFixed32, requiredRepeatedFixed64, requiredMap, requiredAnyValue, requiredStructValue, requiredValueValue, requiredListValueValue, requiredTimeValue, requiredDurationValue, requiredFieldMaskValue, requiredInt32Value, requiredUint32Value, requiredInt64Value, requiredUint64Value, requiredFloatValue, requiredDoubleValue, requiredStringValue, requiredBoolValue, requiredBytesValue, requiredRepeatedAnyValue, requiredRepeatedStructValue, requiredRepeatedValueValue, requiredRepeatedListValueValue, requiredRepeatedTimeValue, requiredRepeatedDurationValue, requiredRepeatedFieldMaskValue, requiredRepeatedInt32Value, requiredRepeatedUint32Value, requiredRepeatedInt64Value, requiredRepeatedUint64Value, requiredRepeatedFloatValue, requiredRepeatedDoubleValue, requiredRepeatedStringValue, requiredRepeatedBoolValue, requiredRepeatedBytesValue, optionalSingularInt32, optionalSingularInt64, optionalSingularFloat, optionalSingularDouble, optionalSingularBool, optionalSingularEnum, optionalSingularString, optionalSingularBytes, optionalSingularMessage, optionalSingularResourceName, optionalSingularResourceNameOneof, optionalSingularResourceNameCommon, optionalSingularFixed32, optionalSingularFixed64, optionalRepeatedInt32, optionalRepeatedInt64, optionalRepeatedFloat, optionalRepeatedDouble, optionalRepeatedBool, optionalRepeatedEnum, optionalRepeatedString, optionalRepeatedBytes, optionalRepeatedMessage, optionalRepeatedResourceName, optionalRepeatedResourceNameOneof, optionalRepeatedResourceNameCommon, optionalRepeatedFixed32, optionalRepeatedFixed64, optionalMap, anyValue, structValue, valueValue, listValueValue, timeValue, durationValue, fieldMaskValue, int32Value, uint32Value, int64Value, uint64Value, floatValue, doubleValue, stringValue, boolValue, bytesValue, repeatedAnyValue, repeatedStructValue, repeatedValueValue, repeatedListValueValue, repeatedTimeValue, repeatedDurationValue, repeatedFieldMaskValue, repeatedInt32Value, repeatedUint32Value, repeatedInt64Value, repeatedUint64Value, repeatedFloatValue, repeatedDoubleValue, repeatedStringValue, repeatedBoolValue, repeatedBytesValue);
+   * }
+   * 
+ * + * @param requiredSingularInt32 + * @param requiredSingularInt64 + * @param requiredSingularFloat + * @param requiredSingularDouble + * @param requiredSingularBool + * @param requiredSingularEnum + * @param requiredSingularString + * @param requiredSingularBytes + * @param requiredSingularMessage + * @param requiredSingularResourceName + * @param requiredSingularResourceNameOneof + * @param requiredSingularResourceNameCommon + * @param requiredSingularFixed32 + * @param requiredSingularFixed64 + * @param requiredRepeatedInt32 + * @param requiredRepeatedInt64 + * @param requiredRepeatedFloat + * @param requiredRepeatedDouble + * @param requiredRepeatedBool + * @param requiredRepeatedEnum + * @param requiredRepeatedString + * @param requiredRepeatedBytes + * @param requiredRepeatedMessage + * @param requiredRepeatedResourceName + * @param requiredRepeatedResourceNameOneof + * @param requiredRepeatedResourceNameCommon + * @param requiredRepeatedFixed32 + * @param requiredRepeatedFixed64 + * @param requiredMap + * @param requiredAnyValue + * @param requiredStructValue + * @param requiredValueValue + * @param requiredListValueValue + * @param requiredTimeValue + * @param requiredDurationValue + * @param requiredFieldMaskValue + * @param requiredInt32Value + * @param requiredUint32Value + * @param requiredInt64Value + * @param requiredUint64Value + * @param requiredFloatValue + * @param requiredDoubleValue + * @param requiredStringValue + * @param requiredBoolValue + * @param requiredBytesValue + * @param requiredRepeatedAnyValue + * @param requiredRepeatedStructValue + * @param requiredRepeatedValueValue + * @param requiredRepeatedListValueValue + * @param requiredRepeatedTimeValue + * @param requiredRepeatedDurationValue + * @param requiredRepeatedFieldMaskValue + * @param requiredRepeatedInt32Value + * @param requiredRepeatedUint32Value + * @param requiredRepeatedInt64Value + * @param requiredRepeatedUint64Value + * @param requiredRepeatedFloatValue + * @param requiredRepeatedDoubleValue + * @param requiredRepeatedStringValue + * @param requiredRepeatedBoolValue + * @param requiredRepeatedBytesValue + * @param optionalSingularInt32 + * @param optionalSingularInt64 + * @param optionalSingularFloat + * @param optionalSingularDouble + * @param optionalSingularBool + * @param optionalSingularEnum + * @param optionalSingularString + * @param optionalSingularBytes + * @param optionalSingularMessage + * @param optionalSingularResourceName + * @param optionalSingularResourceNameOneof + * @param optionalSingularResourceNameCommon + * @param optionalSingularFixed32 + * @param optionalSingularFixed64 + * @param optionalRepeatedInt32 + * @param optionalRepeatedInt64 + * @param optionalRepeatedFloat + * @param optionalRepeatedDouble + * @param optionalRepeatedBool + * @param optionalRepeatedEnum + * @param optionalRepeatedString + * @param optionalRepeatedBytes + * @param optionalRepeatedMessage + * @param optionalRepeatedResourceName + * @param optionalRepeatedResourceNameOneof + * @param optionalRepeatedResourceNameCommon + * @param optionalRepeatedFixed32 + * @param optionalRepeatedFixed64 + * @param optionalMap + * @param anyValue + * @param structValue + * @param valueValue + * @param listValueValue + * @param timeValue + * @param durationValue + * @param fieldMaskValue + * @param int32Value + * @param uint32Value + * @param int64Value + * @param uint64Value + * @param floatValue + * @param doubleValue + * @param stringValue + * @param boolValue + * @param bytesValue + * @param repeatedAnyValue + * @param repeatedStructValue + * @param repeatedValueValue + * @param repeatedListValueValue + * @param repeatedTimeValue + * @param repeatedDurationValue + * @param repeatedFieldMaskValue + * @param repeatedInt32Value + * @param repeatedUint32Value + * @param repeatedInt64Value + * @param repeatedUint64Value + * @param repeatedFloatValue + * @param repeatedDoubleValue + * @param repeatedStringValue + * @param repeatedBoolValue + * @param repeatedBytesValue + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final TestOptionalRequiredFlatteningParamsResponse testOptionalRequiredFlatteningParams(int requiredSingularInt32, long requiredSingularInt64, float requiredSingularFloat, double requiredSingularDouble, boolean requiredSingularBool, TestOptionalRequiredFlatteningParamsRequest.InnerEnum requiredSingularEnum, String requiredSingularString, ByteString requiredSingularBytes, TestOptionalRequiredFlatteningParamsRequest.InnerMessage requiredSingularMessage, BookName requiredSingularResourceName, BookName requiredSingularResourceNameOneof, String requiredSingularResourceNameCommon, int requiredSingularFixed32, long requiredSingularFixed64, List requiredRepeatedInt32, List requiredRepeatedInt64, List requiredRepeatedFloat, List requiredRepeatedDouble, List requiredRepeatedBool, List requiredRepeatedEnum, List requiredRepeatedString, List requiredRepeatedBytes, List requiredRepeatedMessage, List requiredRepeatedResourceName, List requiredRepeatedResourceNameOneof, List requiredRepeatedResourceNameCommon, List requiredRepeatedFixed32, List requiredRepeatedFixed64, Map requiredMap, Any requiredAnyValue, Struct requiredStructValue, Value requiredValueValue, ListValue requiredListValueValue, Timestamp requiredTimeValue, Duration requiredDurationValue, FieldMask requiredFieldMaskValue, Int32Value requiredInt32Value, UInt32Value requiredUint32Value, Int64Value requiredInt64Value, UInt64Value requiredUint64Value, FloatValue requiredFloatValue, DoubleValue requiredDoubleValue, StringValue requiredStringValue, BoolValue requiredBoolValue, BytesValue requiredBytesValue, List requiredRepeatedAnyValue, List requiredRepeatedStructValue, List requiredRepeatedValueValue, List requiredRepeatedListValueValue, List requiredRepeatedTimeValue, List requiredRepeatedDurationValue, List requiredRepeatedFieldMaskValue, List requiredRepeatedInt32Value, List requiredRepeatedUint32Value, List requiredRepeatedInt64Value, List requiredRepeatedUint64Value, List requiredRepeatedFloatValue, List requiredRepeatedDoubleValue, List requiredRepeatedStringValue, List requiredRepeatedBoolValue, List requiredRepeatedBytesValue, int optionalSingularInt32, long optionalSingularInt64, float optionalSingularFloat, double optionalSingularDouble, boolean optionalSingularBool, TestOptionalRequiredFlatteningParamsRequest.InnerEnum optionalSingularEnum, String optionalSingularString, ByteString optionalSingularBytes, TestOptionalRequiredFlatteningParamsRequest.InnerMessage optionalSingularMessage, BookName optionalSingularResourceName, BookName optionalSingularResourceNameOneof, String optionalSingularResourceNameCommon, int optionalSingularFixed32, long optionalSingularFixed64, List optionalRepeatedInt32, List optionalRepeatedInt64, List optionalRepeatedFloat, List optionalRepeatedDouble, List optionalRepeatedBool, List optionalRepeatedEnum, List optionalRepeatedString, List optionalRepeatedBytes, List optionalRepeatedMessage, List optionalRepeatedResourceName, List optionalRepeatedResourceNameOneof, List optionalRepeatedResourceNameCommon, List optionalRepeatedFixed32, List optionalRepeatedFixed64, Map optionalMap, Any anyValue, Struct structValue, Value valueValue, ListValue listValueValue, Timestamp timeValue, Duration durationValue, FieldMask fieldMaskValue, Int32Value int32Value, UInt32Value uint32Value, Int64Value int64Value, UInt64Value uint64Value, FloatValue floatValue, DoubleValue doubleValue, StringValue stringValue, BoolValue boolValue, BytesValue bytesValue, List repeatedAnyValue, List repeatedStructValue, List repeatedValueValue, List repeatedListValueValue, List repeatedTimeValue, List repeatedDurationValue, List repeatedFieldMaskValue, List repeatedInt32Value, List repeatedUint32Value, List repeatedInt64Value, List repeatedUint64Value, List repeatedFloatValue, List repeatedDoubleValue, List repeatedStringValue, List repeatedBoolValue, List repeatedBytesValue) { + TestOptionalRequiredFlatteningParamsRequest request = + TestOptionalRequiredFlatteningParamsRequest.newBuilder() + .setRequiredSingularInt32(requiredSingularInt32) + .setRequiredSingularInt64(requiredSingularInt64) + .setRequiredSingularFloat(requiredSingularFloat) + .setRequiredSingularDouble(requiredSingularDouble) + .setRequiredSingularBool(requiredSingularBool) + .setRequiredSingularEnum(requiredSingularEnum) + .setRequiredSingularString(requiredSingularString) + .setRequiredSingularBytes(requiredSingularBytes) + .setRequiredSingularMessage(requiredSingularMessage) + .setRequiredSingularResourceName(requiredSingularResourceName == null ? null : requiredSingularResourceName.toString()) + .setRequiredSingularResourceNameOneof(requiredSingularResourceNameOneof == null ? null : requiredSingularResourceNameOneof.toString()) + .setRequiredSingularResourceNameCommon(requiredSingularResourceNameCommon) + .setRequiredSingularFixed32(requiredSingularFixed32) + .setRequiredSingularFixed64(requiredSingularFixed64) + .addAllRequiredRepeatedInt32(requiredRepeatedInt32) + .addAllRequiredRepeatedInt64(requiredRepeatedInt64) + .addAllRequiredRepeatedFloat(requiredRepeatedFloat) + .addAllRequiredRepeatedDouble(requiredRepeatedDouble) + .addAllRequiredRepeatedBool(requiredRepeatedBool) + .addAllRequiredRepeatedEnum(requiredRepeatedEnum) + .addAllRequiredRepeatedString(requiredRepeatedString) + .addAllRequiredRepeatedBytes(requiredRepeatedBytes) + .addAllRequiredRepeatedMessage(requiredRepeatedMessage) + .addAllRequiredRepeatedResourceName(requiredRepeatedResourceName) + .addAllRequiredRepeatedResourceNameOneof(requiredRepeatedResourceNameOneof) + .addAllRequiredRepeatedResourceNameCommon(requiredRepeatedResourceNameCommon) + .addAllRequiredRepeatedFixed32(requiredRepeatedFixed32) + .addAllRequiredRepeatedFixed64(requiredRepeatedFixed64) + .putAllRequiredMap(requiredMap) + .setRequiredAnyValue(requiredAnyValue) + .setRequiredStructValue(requiredStructValue) + .setRequiredValueValue(requiredValueValue) + .setRequiredListValueValue(requiredListValueValue) + .setRequiredTimeValue(requiredTimeValue) + .setRequiredDurationValue(requiredDurationValue) + .setRequiredFieldMaskValue(requiredFieldMaskValue) + .setRequiredInt32Value(requiredInt32Value) + .setRequiredUint32Value(requiredUint32Value) + .setRequiredInt64Value(requiredInt64Value) + .setRequiredUint64Value(requiredUint64Value) + .setRequiredFloatValue(requiredFloatValue) + .setRequiredDoubleValue(requiredDoubleValue) + .setRequiredStringValue(requiredStringValue) + .setRequiredBoolValue(requiredBoolValue) + .setRequiredBytesValue(requiredBytesValue) + .addAllRequiredRepeatedAnyValue(requiredRepeatedAnyValue) + .addAllRequiredRepeatedStructValue(requiredRepeatedStructValue) + .addAllRequiredRepeatedValueValue(requiredRepeatedValueValue) + .addAllRequiredRepeatedListValueValue(requiredRepeatedListValueValue) + .addAllRequiredRepeatedTimeValue(requiredRepeatedTimeValue) + .addAllRequiredRepeatedDurationValue(requiredRepeatedDurationValue) + .addAllRequiredRepeatedFieldMaskValue(requiredRepeatedFieldMaskValue) + .addAllRequiredRepeatedInt32Value(requiredRepeatedInt32Value) + .addAllRequiredRepeatedUint32Value(requiredRepeatedUint32Value) + .addAllRequiredRepeatedInt64Value(requiredRepeatedInt64Value) + .addAllRequiredRepeatedUint64Value(requiredRepeatedUint64Value) + .addAllRequiredRepeatedFloatValue(requiredRepeatedFloatValue) + .addAllRequiredRepeatedDoubleValue(requiredRepeatedDoubleValue) + .addAllRequiredRepeatedStringValue(requiredRepeatedStringValue) + .addAllRequiredRepeatedBoolValue(requiredRepeatedBoolValue) + .addAllRequiredRepeatedBytesValue(requiredRepeatedBytesValue) + .setOptionalSingularInt32(optionalSingularInt32) + .setOptionalSingularInt64(optionalSingularInt64) + .setOptionalSingularFloat(optionalSingularFloat) + .setOptionalSingularDouble(optionalSingularDouble) + .setOptionalSingularBool(optionalSingularBool) + .setOptionalSingularEnum(optionalSingularEnum) + .setOptionalSingularString(optionalSingularString) + .setOptionalSingularBytes(optionalSingularBytes) + .setOptionalSingularMessage(optionalSingularMessage) + .setOptionalSingularResourceName(optionalSingularResourceName == null ? null : optionalSingularResourceName.toString()) + .setOptionalSingularResourceNameOneof(optionalSingularResourceNameOneof == null ? null : optionalSingularResourceNameOneof.toString()) + .setOptionalSingularResourceNameCommon(optionalSingularResourceNameCommon) + .setOptionalSingularFixed32(optionalSingularFixed32) + .setOptionalSingularFixed64(optionalSingularFixed64) + .addAllOptionalRepeatedInt32(optionalRepeatedInt32) + .addAllOptionalRepeatedInt64(optionalRepeatedInt64) + .addAllOptionalRepeatedFloat(optionalRepeatedFloat) + .addAllOptionalRepeatedDouble(optionalRepeatedDouble) + .addAllOptionalRepeatedBool(optionalRepeatedBool) + .addAllOptionalRepeatedEnum(optionalRepeatedEnum) + .addAllOptionalRepeatedString(optionalRepeatedString) + .addAllOptionalRepeatedBytes(optionalRepeatedBytes) + .addAllOptionalRepeatedMessage(optionalRepeatedMessage) + .addAllOptionalRepeatedResourceName(optionalRepeatedResourceName) + .addAllOptionalRepeatedResourceNameOneof(optionalRepeatedResourceNameOneof) + .addAllOptionalRepeatedResourceNameCommon(optionalRepeatedResourceNameCommon) + .addAllOptionalRepeatedFixed32(optionalRepeatedFixed32) + .addAllOptionalRepeatedFixed64(optionalRepeatedFixed64) + .putAllOptionalMap(optionalMap) + .setAnyValue(anyValue) + .setStructValue(structValue) + .setValueValue(valueValue) + .setListValueValue(listValueValue) + .setTimeValue(timeValue) + .setDurationValue(durationValue) + .setFieldMaskValue(fieldMaskValue) + .setInt32Value(int32Value) + .setUint32Value(uint32Value) + .setInt64Value(int64Value) + .setUint64Value(uint64Value) + .setFloatValue(floatValue) + .setDoubleValue(doubleValue) + .setStringValue(stringValue) + .setBoolValue(boolValue) + .setBytesValue(bytesValue) + .addAllRepeatedAnyValue(repeatedAnyValue) + .addAllRepeatedStructValue(repeatedStructValue) + .addAllRepeatedValueValue(repeatedValueValue) + .addAllRepeatedListValueValue(repeatedListValueValue) + .addAllRepeatedTimeValue(repeatedTimeValue) + .addAllRepeatedDurationValue(repeatedDurationValue) + .addAllRepeatedFieldMaskValue(repeatedFieldMaskValue) + .addAllRepeatedInt32Value(repeatedInt32Value) + .addAllRepeatedUint32Value(repeatedUint32Value) + .addAllRepeatedInt64Value(repeatedInt64Value) + .addAllRepeatedUint64Value(repeatedUint64Value) + .addAllRepeatedFloatValue(repeatedFloatValue) + .addAllRepeatedDoubleValue(repeatedDoubleValue) + .addAllRepeatedStringValue(repeatedStringValue) + .addAllRepeatedBoolValue(repeatedBoolValue) + .addAllRepeatedBytesValue(repeatedBytesValue) + .build(); + return testOptionalRequiredFlatteningParams(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test optional flattening parameters of all types + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   int requiredSingularInt32 = 0;
+   *   long requiredSingularInt64 = 0L;
+   *   float requiredSingularFloat = 0.0F;
+   *   double requiredSingularDouble = 0.0;
+   *   boolean requiredSingularBool = false;
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerEnum requiredSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO;
+   *   String requiredSingularString = "";
+   *   ByteString requiredSingularBytes = ByteString.copyFromUtf8("");
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerMessage requiredSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build();
+   *   BookName requiredSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName requiredSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String requiredSingularResourceNameCommon = "";
+   *   int requiredSingularFixed32 = 0;
+   *   long requiredSingularFixed64 = 0L;
+   *   List<Integer> requiredRepeatedInt32 = new ArrayList<>();
+   *   List<Long> requiredRepeatedInt64 = new ArrayList<>();
+   *   List<Float> requiredRepeatedFloat = new ArrayList<>();
+   *   List<Double> requiredRepeatedDouble = new ArrayList<>();
+   *   List<Boolean> requiredRepeatedBool = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerEnum> requiredRepeatedEnum = new ArrayList<>();
+   *   List<String> requiredRepeatedString = new ArrayList<>();
+   *   List<ByteString> requiredRepeatedBytes = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerMessage> requiredRepeatedMessage = new ArrayList<>();
+   *   List<String> requiredRepeatedResourceName = new ArrayList<>();
+   *   List<String> requiredRepeatedResourceNameOneof = new ArrayList<>();
+   *   List<String> requiredRepeatedResourceNameCommon = new ArrayList<>();
+   *   List<Integer> requiredRepeatedFixed32 = new ArrayList<>();
+   *   List<Long> requiredRepeatedFixed64 = new ArrayList<>();
+   *   Map<Integer, String> requiredMap = new HashMap<>();
+   *   Any requiredAnyValue = Any.newBuilder().build();
+   *   Struct requiredStructValue = Struct.newBuilder().build();
+   *   Value requiredValueValue = Value.newBuilder().build();
+   *   ListValue requiredListValueValue = ListValue.newBuilder().build();
+   *   Timestamp requiredTimeValue = Timestamp.newBuilder().build();
+   *   Duration requiredDurationValue = Duration.newBuilder().build();
+   *   FieldMask requiredFieldMaskValue = FieldMask.newBuilder().build();
+   *   Int32Value requiredInt32Value = Int32Value.newBuilder().build();
+   *   UInt32Value requiredUint32Value = UInt32Value.newBuilder().build();
+   *   Int64Value requiredInt64Value = Int64Value.newBuilder().build();
+   *   UInt64Value requiredUint64Value = UInt64Value.newBuilder().build();
+   *   FloatValue requiredFloatValue = FloatValue.newBuilder().build();
+   *   DoubleValue requiredDoubleValue = DoubleValue.newBuilder().build();
+   *   StringValue requiredStringValue = StringValue.newBuilder().build();
+   *   BoolValue requiredBoolValue = BoolValue.newBuilder().build();
+   *   BytesValue requiredBytesValue = BytesValue.newBuilder().build();
+   *   List<Any> requiredRepeatedAnyValue = new ArrayList<>();
+   *   List<Struct> requiredRepeatedStructValue = new ArrayList<>();
+   *   List<Value> requiredRepeatedValueValue = new ArrayList<>();
+   *   List<ListValue> requiredRepeatedListValueValue = new ArrayList<>();
+   *   List<Timestamp> requiredRepeatedTimeValue = new ArrayList<>();
+   *   List<Duration> requiredRepeatedDurationValue = new ArrayList<>();
+   *   List<FieldMask> requiredRepeatedFieldMaskValue = new ArrayList<>();
+   *   List<Int32Value> requiredRepeatedInt32Value = new ArrayList<>();
+   *   List<UInt32Value> requiredRepeatedUint32Value = new ArrayList<>();
+   *   List<Int64Value> requiredRepeatedInt64Value = new ArrayList<>();
+   *   List<UInt64Value> requiredRepeatedUint64Value = new ArrayList<>();
+   *   List<FloatValue> requiredRepeatedFloatValue = new ArrayList<>();
+   *   List<DoubleValue> requiredRepeatedDoubleValue = new ArrayList<>();
+   *   List<StringValue> requiredRepeatedStringValue = new ArrayList<>();
+   *   List<BoolValue> requiredRepeatedBoolValue = new ArrayList<>();
+   *   List<BytesValue> requiredRepeatedBytesValue = new ArrayList<>();
+   *   int optionalSingularInt32 = 0;
+   *   long optionalSingularInt64 = 0L;
+   *   float optionalSingularFloat = 0.0F;
+   *   double optionalSingularDouble = 0.0;
+   *   boolean optionalSingularBool = false;
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerEnum optionalSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO;
+   *   String optionalSingularString = "";
+   *   ByteString optionalSingularBytes = ByteString.copyFromUtf8("");
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerMessage optionalSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build();
+   *   BookName optionalSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName optionalSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String optionalSingularResourceNameCommon = "";
+   *   int optionalSingularFixed32 = 0;
+   *   long optionalSingularFixed64 = 0L;
+   *   List<Integer> optionalRepeatedInt32 = new ArrayList<>();
+   *   List<Long> optionalRepeatedInt64 = new ArrayList<>();
+   *   List<Float> optionalRepeatedFloat = new ArrayList<>();
+   *   List<Double> optionalRepeatedDouble = new ArrayList<>();
+   *   List<Boolean> optionalRepeatedBool = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerEnum> optionalRepeatedEnum = new ArrayList<>();
+   *   List<String> optionalRepeatedString = new ArrayList<>();
+   *   List<ByteString> optionalRepeatedBytes = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerMessage> optionalRepeatedMessage = new ArrayList<>();
+   *   List<String> optionalRepeatedResourceName = new ArrayList<>();
+   *   List<String> optionalRepeatedResourceNameOneof = new ArrayList<>();
+   *   List<String> optionalRepeatedResourceNameCommon = new ArrayList<>();
+   *   List<Integer> optionalRepeatedFixed32 = new ArrayList<>();
+   *   List<Long> optionalRepeatedFixed64 = new ArrayList<>();
+   *   Map<Integer, String> optionalMap = new HashMap<>();
+   *   Any anyValue = Any.newBuilder().build();
+   *   Struct structValue = Struct.newBuilder().build();
+   *   Value valueValue = Value.newBuilder().build();
+   *   ListValue listValueValue = ListValue.newBuilder().build();
+   *   Timestamp timeValue = Timestamp.newBuilder().build();
+   *   Duration durationValue = Duration.newBuilder().build();
+   *   FieldMask fieldMaskValue = FieldMask.newBuilder().build();
+   *   Int32Value int32Value = Int32Value.newBuilder().build();
+   *   UInt32Value uint32Value = UInt32Value.newBuilder().build();
+   *   Int64Value int64Value = Int64Value.newBuilder().build();
+   *   UInt64Value uint64Value = UInt64Value.newBuilder().build();
+   *   FloatValue floatValue = FloatValue.newBuilder().build();
+   *   DoubleValue doubleValue = DoubleValue.newBuilder().build();
+   *   StringValue stringValue = StringValue.newBuilder().build();
+   *   BoolValue boolValue = BoolValue.newBuilder().build();
+   *   BytesValue bytesValue = BytesValue.newBuilder().build();
+   *   List<Any> repeatedAnyValue = new ArrayList<>();
+   *   List<Struct> repeatedStructValue = new ArrayList<>();
+   *   List<Value> repeatedValueValue = new ArrayList<>();
+   *   List<ListValue> repeatedListValueValue = new ArrayList<>();
+   *   List<Timestamp> repeatedTimeValue = new ArrayList<>();
+   *   List<Duration> repeatedDurationValue = new ArrayList<>();
+   *   List<FieldMask> repeatedFieldMaskValue = new ArrayList<>();
+   *   List<Int32Value> repeatedInt32Value = new ArrayList<>();
+   *   List<UInt32Value> repeatedUint32Value = new ArrayList<>();
+   *   List<Int64Value> repeatedInt64Value = new ArrayList<>();
+   *   List<UInt64Value> repeatedUint64Value = new ArrayList<>();
+   *   List<FloatValue> repeatedFloatValue = new ArrayList<>();
+   *   List<DoubleValue> repeatedDoubleValue = new ArrayList<>();
+   *   List<StringValue> repeatedStringValue = new ArrayList<>();
+   *   List<BoolValue> repeatedBoolValue = new ArrayList<>();
+   *   List<BytesValue> repeatedBytesValue = new ArrayList<>();
+   *   TestOptionalRequiredFlatteningParamsResponse response = libraryServiceClient.testOptionalRequiredFlatteningParams(requiredSingularInt32, requiredSingularInt64, requiredSingularFloat, requiredSingularDouble, requiredSingularBool, requiredSingularEnum, requiredSingularString, requiredSingularBytes, requiredSingularMessage, requiredSingularResourceName.toString(), requiredSingularResourceNameOneof.toString(), requiredSingularResourceNameCommon, requiredSingularFixed32, requiredSingularFixed64, requiredRepeatedInt32, requiredRepeatedInt64, requiredRepeatedFloat, requiredRepeatedDouble, requiredRepeatedBool, requiredRepeatedEnum, requiredRepeatedString, requiredRepeatedBytes, requiredRepeatedMessage, requiredRepeatedResourceName, requiredRepeatedResourceNameOneof, requiredRepeatedResourceNameCommon, requiredRepeatedFixed32, requiredRepeatedFixed64, requiredMap, requiredAnyValue, requiredStructValue, requiredValueValue, requiredListValueValue, requiredTimeValue, requiredDurationValue, requiredFieldMaskValue, requiredInt32Value, requiredUint32Value, requiredInt64Value, requiredUint64Value, requiredFloatValue, requiredDoubleValue, requiredStringValue, requiredBoolValue, requiredBytesValue, requiredRepeatedAnyValue, requiredRepeatedStructValue, requiredRepeatedValueValue, requiredRepeatedListValueValue, requiredRepeatedTimeValue, requiredRepeatedDurationValue, requiredRepeatedFieldMaskValue, requiredRepeatedInt32Value, requiredRepeatedUint32Value, requiredRepeatedInt64Value, requiredRepeatedUint64Value, requiredRepeatedFloatValue, requiredRepeatedDoubleValue, requiredRepeatedStringValue, requiredRepeatedBoolValue, requiredRepeatedBytesValue, optionalSingularInt32, optionalSingularInt64, optionalSingularFloat, optionalSingularDouble, optionalSingularBool, optionalSingularEnum, optionalSingularString, optionalSingularBytes, optionalSingularMessage, optionalSingularResourceName.toString(), optionalSingularResourceNameOneof.toString(), optionalSingularResourceNameCommon, optionalSingularFixed32, optionalSingularFixed64, optionalRepeatedInt32, optionalRepeatedInt64, optionalRepeatedFloat, optionalRepeatedDouble, optionalRepeatedBool, optionalRepeatedEnum, optionalRepeatedString, optionalRepeatedBytes, optionalRepeatedMessage, optionalRepeatedResourceName, optionalRepeatedResourceNameOneof, optionalRepeatedResourceNameCommon, optionalRepeatedFixed32, optionalRepeatedFixed64, optionalMap, anyValue, structValue, valueValue, listValueValue, timeValue, durationValue, fieldMaskValue, int32Value, uint32Value, int64Value, uint64Value, floatValue, doubleValue, stringValue, boolValue, bytesValue, repeatedAnyValue, repeatedStructValue, repeatedValueValue, repeatedListValueValue, repeatedTimeValue, repeatedDurationValue, repeatedFieldMaskValue, repeatedInt32Value, repeatedUint32Value, repeatedInt64Value, repeatedUint64Value, repeatedFloatValue, repeatedDoubleValue, repeatedStringValue, repeatedBoolValue, repeatedBytesValue);
+   * }
+   * 
+ * + * @param requiredSingularInt32 + * @param requiredSingularInt64 + * @param requiredSingularFloat + * @param requiredSingularDouble + * @param requiredSingularBool + * @param requiredSingularEnum + * @param requiredSingularString + * @param requiredSingularBytes + * @param requiredSingularMessage + * @param requiredSingularResourceName + * @param requiredSingularResourceNameOneof + * @param requiredSingularResourceNameCommon + * @param requiredSingularFixed32 + * @param requiredSingularFixed64 + * @param requiredRepeatedInt32 + * @param requiredRepeatedInt64 + * @param requiredRepeatedFloat + * @param requiredRepeatedDouble + * @param requiredRepeatedBool + * @param requiredRepeatedEnum + * @param requiredRepeatedString + * @param requiredRepeatedBytes + * @param requiredRepeatedMessage + * @param requiredRepeatedResourceName + * @param requiredRepeatedResourceNameOneof + * @param requiredRepeatedResourceNameCommon + * @param requiredRepeatedFixed32 + * @param requiredRepeatedFixed64 + * @param requiredMap + * @param requiredAnyValue + * @param requiredStructValue + * @param requiredValueValue + * @param requiredListValueValue + * @param requiredTimeValue + * @param requiredDurationValue + * @param requiredFieldMaskValue + * @param requiredInt32Value + * @param requiredUint32Value + * @param requiredInt64Value + * @param requiredUint64Value + * @param requiredFloatValue + * @param requiredDoubleValue + * @param requiredStringValue + * @param requiredBoolValue + * @param requiredBytesValue + * @param requiredRepeatedAnyValue + * @param requiredRepeatedStructValue + * @param requiredRepeatedValueValue + * @param requiredRepeatedListValueValue + * @param requiredRepeatedTimeValue + * @param requiredRepeatedDurationValue + * @param requiredRepeatedFieldMaskValue + * @param requiredRepeatedInt32Value + * @param requiredRepeatedUint32Value + * @param requiredRepeatedInt64Value + * @param requiredRepeatedUint64Value + * @param requiredRepeatedFloatValue + * @param requiredRepeatedDoubleValue + * @param requiredRepeatedStringValue + * @param requiredRepeatedBoolValue + * @param requiredRepeatedBytesValue + * @param optionalSingularInt32 + * @param optionalSingularInt64 + * @param optionalSingularFloat + * @param optionalSingularDouble + * @param optionalSingularBool + * @param optionalSingularEnum + * @param optionalSingularString + * @param optionalSingularBytes + * @param optionalSingularMessage + * @param optionalSingularResourceName + * @param optionalSingularResourceNameOneof + * @param optionalSingularResourceNameCommon + * @param optionalSingularFixed32 + * @param optionalSingularFixed64 + * @param optionalRepeatedInt32 + * @param optionalRepeatedInt64 + * @param optionalRepeatedFloat + * @param optionalRepeatedDouble + * @param optionalRepeatedBool + * @param optionalRepeatedEnum + * @param optionalRepeatedString + * @param optionalRepeatedBytes + * @param optionalRepeatedMessage + * @param optionalRepeatedResourceName + * @param optionalRepeatedResourceNameOneof + * @param optionalRepeatedResourceNameCommon + * @param optionalRepeatedFixed32 + * @param optionalRepeatedFixed64 + * @param optionalMap + * @param anyValue + * @param structValue + * @param valueValue + * @param listValueValue + * @param timeValue + * @param durationValue + * @param fieldMaskValue + * @param int32Value + * @param uint32Value + * @param int64Value + * @param uint64Value + * @param floatValue + * @param doubleValue + * @param stringValue + * @param boolValue + * @param bytesValue + * @param repeatedAnyValue + * @param repeatedStructValue + * @param repeatedValueValue + * @param repeatedListValueValue + * @param repeatedTimeValue + * @param repeatedDurationValue + * @param repeatedFieldMaskValue + * @param repeatedInt32Value + * @param repeatedUint32Value + * @param repeatedInt64Value + * @param repeatedUint64Value + * @param repeatedFloatValue + * @param repeatedDoubleValue + * @param repeatedStringValue + * @param repeatedBoolValue + * @param repeatedBytesValue + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final TestOptionalRequiredFlatteningParamsResponse testOptionalRequiredFlatteningParams(int requiredSingularInt32, long requiredSingularInt64, float requiredSingularFloat, double requiredSingularDouble, boolean requiredSingularBool, TestOptionalRequiredFlatteningParamsRequest.InnerEnum requiredSingularEnum, String requiredSingularString, ByteString requiredSingularBytes, TestOptionalRequiredFlatteningParamsRequest.InnerMessage requiredSingularMessage, String requiredSingularResourceName, String requiredSingularResourceNameOneof, String requiredSingularResourceNameCommon, int requiredSingularFixed32, long requiredSingularFixed64, List requiredRepeatedInt32, List requiredRepeatedInt64, List requiredRepeatedFloat, List requiredRepeatedDouble, List requiredRepeatedBool, List requiredRepeatedEnum, List requiredRepeatedString, List requiredRepeatedBytes, List requiredRepeatedMessage, List requiredRepeatedResourceName, List requiredRepeatedResourceNameOneof, List requiredRepeatedResourceNameCommon, List requiredRepeatedFixed32, List requiredRepeatedFixed64, Map requiredMap, Any requiredAnyValue, Struct requiredStructValue, Value requiredValueValue, ListValue requiredListValueValue, Timestamp requiredTimeValue, Duration requiredDurationValue, FieldMask requiredFieldMaskValue, Int32Value requiredInt32Value, UInt32Value requiredUint32Value, Int64Value requiredInt64Value, UInt64Value requiredUint64Value, FloatValue requiredFloatValue, DoubleValue requiredDoubleValue, StringValue requiredStringValue, BoolValue requiredBoolValue, BytesValue requiredBytesValue, List requiredRepeatedAnyValue, List requiredRepeatedStructValue, List requiredRepeatedValueValue, List requiredRepeatedListValueValue, List requiredRepeatedTimeValue, List requiredRepeatedDurationValue, List requiredRepeatedFieldMaskValue, List requiredRepeatedInt32Value, List requiredRepeatedUint32Value, List requiredRepeatedInt64Value, List requiredRepeatedUint64Value, List requiredRepeatedFloatValue, List requiredRepeatedDoubleValue, List requiredRepeatedStringValue, List requiredRepeatedBoolValue, List requiredRepeatedBytesValue, int optionalSingularInt32, long optionalSingularInt64, float optionalSingularFloat, double optionalSingularDouble, boolean optionalSingularBool, TestOptionalRequiredFlatteningParamsRequest.InnerEnum optionalSingularEnum, String optionalSingularString, ByteString optionalSingularBytes, TestOptionalRequiredFlatteningParamsRequest.InnerMessage optionalSingularMessage, String optionalSingularResourceName, String optionalSingularResourceNameOneof, String optionalSingularResourceNameCommon, int optionalSingularFixed32, long optionalSingularFixed64, List optionalRepeatedInt32, List optionalRepeatedInt64, List optionalRepeatedFloat, List optionalRepeatedDouble, List optionalRepeatedBool, List optionalRepeatedEnum, List optionalRepeatedString, List optionalRepeatedBytes, List optionalRepeatedMessage, List optionalRepeatedResourceName, List optionalRepeatedResourceNameOneof, List optionalRepeatedResourceNameCommon, List optionalRepeatedFixed32, List optionalRepeatedFixed64, Map optionalMap, Any anyValue, Struct structValue, Value valueValue, ListValue listValueValue, Timestamp timeValue, Duration durationValue, FieldMask fieldMaskValue, Int32Value int32Value, UInt32Value uint32Value, Int64Value int64Value, UInt64Value uint64Value, FloatValue floatValue, DoubleValue doubleValue, StringValue stringValue, BoolValue boolValue, BytesValue bytesValue, List repeatedAnyValue, List repeatedStructValue, List repeatedValueValue, List repeatedListValueValue, List repeatedTimeValue, List repeatedDurationValue, List repeatedFieldMaskValue, List repeatedInt32Value, List repeatedUint32Value, List repeatedInt64Value, List repeatedUint64Value, List repeatedFloatValue, List repeatedDoubleValue, List repeatedStringValue, List repeatedBoolValue, List repeatedBytesValue) { + TestOptionalRequiredFlatteningParamsRequest request = + TestOptionalRequiredFlatteningParamsRequest.newBuilder() + .setRequiredSingularInt32(requiredSingularInt32) + .setRequiredSingularInt64(requiredSingularInt64) + .setRequiredSingularFloat(requiredSingularFloat) + .setRequiredSingularDouble(requiredSingularDouble) + .setRequiredSingularBool(requiredSingularBool) + .setRequiredSingularEnum(requiredSingularEnum) + .setRequiredSingularString(requiredSingularString) + .setRequiredSingularBytes(requiredSingularBytes) + .setRequiredSingularMessage(requiredSingularMessage) + .setRequiredSingularResourceName(requiredSingularResourceName) + .setRequiredSingularResourceNameOneof(requiredSingularResourceNameOneof) + .setRequiredSingularResourceNameCommon(requiredSingularResourceNameCommon) + .setRequiredSingularFixed32(requiredSingularFixed32) + .setRequiredSingularFixed64(requiredSingularFixed64) + .addAllRequiredRepeatedInt32(requiredRepeatedInt32) + .addAllRequiredRepeatedInt64(requiredRepeatedInt64) + .addAllRequiredRepeatedFloat(requiredRepeatedFloat) + .addAllRequiredRepeatedDouble(requiredRepeatedDouble) + .addAllRequiredRepeatedBool(requiredRepeatedBool) + .addAllRequiredRepeatedEnum(requiredRepeatedEnum) + .addAllRequiredRepeatedString(requiredRepeatedString) + .addAllRequiredRepeatedBytes(requiredRepeatedBytes) + .addAllRequiredRepeatedMessage(requiredRepeatedMessage) + .addAllRequiredRepeatedResourceName(requiredRepeatedResourceName) + .addAllRequiredRepeatedResourceNameOneof(requiredRepeatedResourceNameOneof) + .addAllRequiredRepeatedResourceNameCommon(requiredRepeatedResourceNameCommon) + .addAllRequiredRepeatedFixed32(requiredRepeatedFixed32) + .addAllRequiredRepeatedFixed64(requiredRepeatedFixed64) + .putAllRequiredMap(requiredMap) + .setRequiredAnyValue(requiredAnyValue) + .setRequiredStructValue(requiredStructValue) + .setRequiredValueValue(requiredValueValue) + .setRequiredListValueValue(requiredListValueValue) + .setRequiredTimeValue(requiredTimeValue) + .setRequiredDurationValue(requiredDurationValue) + .setRequiredFieldMaskValue(requiredFieldMaskValue) + .setRequiredInt32Value(requiredInt32Value) + .setRequiredUint32Value(requiredUint32Value) + .setRequiredInt64Value(requiredInt64Value) + .setRequiredUint64Value(requiredUint64Value) + .setRequiredFloatValue(requiredFloatValue) + .setRequiredDoubleValue(requiredDoubleValue) + .setRequiredStringValue(requiredStringValue) + .setRequiredBoolValue(requiredBoolValue) + .setRequiredBytesValue(requiredBytesValue) + .addAllRequiredRepeatedAnyValue(requiredRepeatedAnyValue) + .addAllRequiredRepeatedStructValue(requiredRepeatedStructValue) + .addAllRequiredRepeatedValueValue(requiredRepeatedValueValue) + .addAllRequiredRepeatedListValueValue(requiredRepeatedListValueValue) + .addAllRequiredRepeatedTimeValue(requiredRepeatedTimeValue) + .addAllRequiredRepeatedDurationValue(requiredRepeatedDurationValue) + .addAllRequiredRepeatedFieldMaskValue(requiredRepeatedFieldMaskValue) + .addAllRequiredRepeatedInt32Value(requiredRepeatedInt32Value) + .addAllRequiredRepeatedUint32Value(requiredRepeatedUint32Value) + .addAllRequiredRepeatedInt64Value(requiredRepeatedInt64Value) + .addAllRequiredRepeatedUint64Value(requiredRepeatedUint64Value) + .addAllRequiredRepeatedFloatValue(requiredRepeatedFloatValue) + .addAllRequiredRepeatedDoubleValue(requiredRepeatedDoubleValue) + .addAllRequiredRepeatedStringValue(requiredRepeatedStringValue) + .addAllRequiredRepeatedBoolValue(requiredRepeatedBoolValue) + .addAllRequiredRepeatedBytesValue(requiredRepeatedBytesValue) + .setOptionalSingularInt32(optionalSingularInt32) + .setOptionalSingularInt64(optionalSingularInt64) + .setOptionalSingularFloat(optionalSingularFloat) + .setOptionalSingularDouble(optionalSingularDouble) + .setOptionalSingularBool(optionalSingularBool) + .setOptionalSingularEnum(optionalSingularEnum) + .setOptionalSingularString(optionalSingularString) + .setOptionalSingularBytes(optionalSingularBytes) + .setOptionalSingularMessage(optionalSingularMessage) + .setOptionalSingularResourceName(optionalSingularResourceName) + .setOptionalSingularResourceNameOneof(optionalSingularResourceNameOneof) + .setOptionalSingularResourceNameCommon(optionalSingularResourceNameCommon) + .setOptionalSingularFixed32(optionalSingularFixed32) + .setOptionalSingularFixed64(optionalSingularFixed64) + .addAllOptionalRepeatedInt32(optionalRepeatedInt32) + .addAllOptionalRepeatedInt64(optionalRepeatedInt64) + .addAllOptionalRepeatedFloat(optionalRepeatedFloat) + .addAllOptionalRepeatedDouble(optionalRepeatedDouble) + .addAllOptionalRepeatedBool(optionalRepeatedBool) + .addAllOptionalRepeatedEnum(optionalRepeatedEnum) + .addAllOptionalRepeatedString(optionalRepeatedString) + .addAllOptionalRepeatedBytes(optionalRepeatedBytes) + .addAllOptionalRepeatedMessage(optionalRepeatedMessage) + .addAllOptionalRepeatedResourceName(optionalRepeatedResourceName) + .addAllOptionalRepeatedResourceNameOneof(optionalRepeatedResourceNameOneof) + .addAllOptionalRepeatedResourceNameCommon(optionalRepeatedResourceNameCommon) + .addAllOptionalRepeatedFixed32(optionalRepeatedFixed32) + .addAllOptionalRepeatedFixed64(optionalRepeatedFixed64) + .putAllOptionalMap(optionalMap) + .setAnyValue(anyValue) + .setStructValue(structValue) + .setValueValue(valueValue) + .setListValueValue(listValueValue) + .setTimeValue(timeValue) + .setDurationValue(durationValue) + .setFieldMaskValue(fieldMaskValue) + .setInt32Value(int32Value) + .setUint32Value(uint32Value) + .setInt64Value(int64Value) + .setUint64Value(uint64Value) + .setFloatValue(floatValue) + .setDoubleValue(doubleValue) + .setStringValue(stringValue) + .setBoolValue(boolValue) + .setBytesValue(bytesValue) + .addAllRepeatedAnyValue(repeatedAnyValue) + .addAllRepeatedStructValue(repeatedStructValue) + .addAllRepeatedValueValue(repeatedValueValue) + .addAllRepeatedListValueValue(repeatedListValueValue) + .addAllRepeatedTimeValue(repeatedTimeValue) + .addAllRepeatedDurationValue(repeatedDurationValue) + .addAllRepeatedFieldMaskValue(repeatedFieldMaskValue) + .addAllRepeatedInt32Value(repeatedInt32Value) + .addAllRepeatedUint32Value(repeatedUint32Value) + .addAllRepeatedInt64Value(repeatedInt64Value) + .addAllRepeatedUint64Value(repeatedUint64Value) + .addAllRepeatedFloatValue(repeatedFloatValue) + .addAllRepeatedDoubleValue(repeatedDoubleValue) + .addAllRepeatedStringValue(repeatedStringValue) + .addAllRepeatedBoolValue(repeatedBoolValue) + .addAllRepeatedBytesValue(repeatedBytesValue) + .build(); + return testOptionalRequiredFlatteningParams(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test optional flattening parameters of all types + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   int requiredSingularInt32 = 0;
+   *   long requiredSingularInt64 = 0L;
+   *   float requiredSingularFloat = 0.0F;
+   *   double requiredSingularDouble = 0.0;
+   *   boolean requiredSingularBool = false;
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerEnum requiredSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO;
+   *   String requiredSingularString = "";
+   *   ByteString requiredSingularBytes = ByteString.copyFromUtf8("");
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerMessage requiredSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build();
+   *   BookName requiredSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName requiredSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String requiredSingularResourceNameCommon = "";
+   *   int requiredSingularFixed32 = 0;
+   *   long requiredSingularFixed64 = 0L;
+   *   List<Integer> requiredRepeatedInt32 = new ArrayList<>();
+   *   List<Long> requiredRepeatedInt64 = new ArrayList<>();
+   *   List<Float> requiredRepeatedFloat = new ArrayList<>();
+   *   List<Double> requiredRepeatedDouble = new ArrayList<>();
+   *   List<Boolean> requiredRepeatedBool = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerEnum> requiredRepeatedEnum = new ArrayList<>();
+   *   List<String> requiredRepeatedString = new ArrayList<>();
+   *   List<ByteString> requiredRepeatedBytes = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerMessage> requiredRepeatedMessage = new ArrayList<>();
+   *   List<BookName> requiredRepeatedResourceName = new ArrayList<>();
+   *   List<BookName> requiredRepeatedResourceNameOneof = new ArrayList<>();
+   *   List<String> requiredRepeatedResourceNameCommon = new ArrayList<>();
+   *   List<Integer> requiredRepeatedFixed32 = new ArrayList<>();
+   *   List<Long> requiredRepeatedFixed64 = new ArrayList<>();
+   *   Map<Integer, String> requiredMap = new HashMap<>();
+   *   Any requiredAnyValue = Any.newBuilder().build();
+   *   Struct requiredStructValue = Struct.newBuilder().build();
+   *   Value requiredValueValue = Value.newBuilder().build();
+   *   ListValue requiredListValueValue = ListValue.newBuilder().build();
+   *   Timestamp requiredTimeValue = Timestamp.newBuilder().build();
+   *   Duration requiredDurationValue = Duration.newBuilder().build();
+   *   FieldMask requiredFieldMaskValue = FieldMask.newBuilder().build();
+   *   Int32Value requiredInt32Value = Int32Value.newBuilder().build();
+   *   UInt32Value requiredUint32Value = UInt32Value.newBuilder().build();
+   *   Int64Value requiredInt64Value = Int64Value.newBuilder().build();
+   *   UInt64Value requiredUint64Value = UInt64Value.newBuilder().build();
+   *   FloatValue requiredFloatValue = FloatValue.newBuilder().build();
+   *   DoubleValue requiredDoubleValue = DoubleValue.newBuilder().build();
+   *   StringValue requiredStringValue = StringValue.newBuilder().build();
+   *   BoolValue requiredBoolValue = BoolValue.newBuilder().build();
+   *   BytesValue requiredBytesValue = BytesValue.newBuilder().build();
+   *   List<Any> requiredRepeatedAnyValue = new ArrayList<>();
+   *   List<Struct> requiredRepeatedStructValue = new ArrayList<>();
+   *   List<Value> requiredRepeatedValueValue = new ArrayList<>();
+   *   List<ListValue> requiredRepeatedListValueValue = new ArrayList<>();
+   *   List<Timestamp> requiredRepeatedTimeValue = new ArrayList<>();
+   *   List<Duration> requiredRepeatedDurationValue = new ArrayList<>();
+   *   List<FieldMask> requiredRepeatedFieldMaskValue = new ArrayList<>();
+   *   List<Int32Value> requiredRepeatedInt32Value = new ArrayList<>();
+   *   List<UInt32Value> requiredRepeatedUint32Value = new ArrayList<>();
+   *   List<Int64Value> requiredRepeatedInt64Value = new ArrayList<>();
+   *   List<UInt64Value> requiredRepeatedUint64Value = new ArrayList<>();
+   *   List<FloatValue> requiredRepeatedFloatValue = new ArrayList<>();
+   *   List<DoubleValue> requiredRepeatedDoubleValue = new ArrayList<>();
+   *   List<StringValue> requiredRepeatedStringValue = new ArrayList<>();
+   *   List<BoolValue> requiredRepeatedBoolValue = new ArrayList<>();
+   *   List<BytesValue> requiredRepeatedBytesValue = new ArrayList<>();
+   *   TestOptionalRequiredFlatteningParamsRequest request = TestOptionalRequiredFlatteningParamsRequest.newBuilder()
+   *     .setRequiredSingularInt32(requiredSingularInt32)
+   *     .setRequiredSingularInt64(requiredSingularInt64)
+   *     .setRequiredSingularFloat(requiredSingularFloat)
+   *     .setRequiredSingularDouble(requiredSingularDouble)
+   *     .setRequiredSingularBool(requiredSingularBool)
+   *     .setRequiredSingularEnum(requiredSingularEnum)
+   *     .setRequiredSingularString(requiredSingularString)
+   *     .setRequiredSingularBytes(requiredSingularBytes)
+   *     .setRequiredSingularMessage(requiredSingularMessage)
+   *     .setRequiredSingularResourceName(requiredSingularResourceName.toString())
+   *     .setRequiredSingularResourceNameOneof(requiredSingularResourceNameOneof.toString())
+   *     .setRequiredSingularResourceNameCommon(requiredSingularResourceNameCommon)
+   *     .setRequiredSingularFixed32(requiredSingularFixed32)
+   *     .setRequiredSingularFixed64(requiredSingularFixed64)
+   *     .addAllRequiredRepeatedInt32(requiredRepeatedInt32)
+   *     .addAllRequiredRepeatedInt64(requiredRepeatedInt64)
+   *     .addAllRequiredRepeatedFloat(requiredRepeatedFloat)
+   *     .addAllRequiredRepeatedDouble(requiredRepeatedDouble)
+   *     .addAllRequiredRepeatedBool(requiredRepeatedBool)
+   *     .addAllRequiredRepeatedEnum(requiredRepeatedEnum)
+   *     .addAllRequiredRepeatedString(requiredRepeatedString)
+   *     .addAllRequiredRepeatedBytes(requiredRepeatedBytes)
+   *     .addAllRequiredRepeatedMessage(requiredRepeatedMessage)
+   *     .addAllRequiredRepeatedResourceName(BookName.toStringList(requiredRepeatedResourceName))
+   *     .addAllRequiredRepeatedResourceNameOneof(BookName.toStringList(requiredRepeatedResourceNameOneof))
+   *     .addAllRequiredRepeatedResourceNameCommon(requiredRepeatedResourceNameCommon)
+   *     .addAllRequiredRepeatedFixed32(requiredRepeatedFixed32)
+   *     .addAllRequiredRepeatedFixed64(requiredRepeatedFixed64)
+   *     .putAllRequiredMap(requiredMap)
+   *     .setRequiredAnyValue(requiredAnyValue)
+   *     .setRequiredStructValue(requiredStructValue)
+   *     .setRequiredValueValue(requiredValueValue)
+   *     .setRequiredListValueValue(requiredListValueValue)
+   *     .setRequiredTimeValue(requiredTimeValue)
+   *     .setRequiredDurationValue(requiredDurationValue)
+   *     .setRequiredFieldMaskValue(requiredFieldMaskValue)
+   *     .setRequiredInt32Value(requiredInt32Value)
+   *     .setRequiredUint32Value(requiredUint32Value)
+   *     .setRequiredInt64Value(requiredInt64Value)
+   *     .setRequiredUint64Value(requiredUint64Value)
+   *     .setRequiredFloatValue(requiredFloatValue)
+   *     .setRequiredDoubleValue(requiredDoubleValue)
+   *     .setRequiredStringValue(requiredStringValue)
+   *     .setRequiredBoolValue(requiredBoolValue)
+   *     .setRequiredBytesValue(requiredBytesValue)
+   *     .addAllRequiredRepeatedAnyValue(requiredRepeatedAnyValue)
+   *     .addAllRequiredRepeatedStructValue(requiredRepeatedStructValue)
+   *     .addAllRequiredRepeatedValueValue(requiredRepeatedValueValue)
+   *     .addAllRequiredRepeatedListValueValue(requiredRepeatedListValueValue)
+   *     .addAllRequiredRepeatedTimeValue(requiredRepeatedTimeValue)
+   *     .addAllRequiredRepeatedDurationValue(requiredRepeatedDurationValue)
+   *     .addAllRequiredRepeatedFieldMaskValue(requiredRepeatedFieldMaskValue)
+   *     .addAllRequiredRepeatedInt32Value(requiredRepeatedInt32Value)
+   *     .addAllRequiredRepeatedUint32Value(requiredRepeatedUint32Value)
+   *     .addAllRequiredRepeatedInt64Value(requiredRepeatedInt64Value)
+   *     .addAllRequiredRepeatedUint64Value(requiredRepeatedUint64Value)
+   *     .addAllRequiredRepeatedFloatValue(requiredRepeatedFloatValue)
+   *     .addAllRequiredRepeatedDoubleValue(requiredRepeatedDoubleValue)
+   *     .addAllRequiredRepeatedStringValue(requiredRepeatedStringValue)
+   *     .addAllRequiredRepeatedBoolValue(requiredRepeatedBoolValue)
+   *     .addAllRequiredRepeatedBytesValue(requiredRepeatedBytesValue)
+   *     .build();
+   *   TestOptionalRequiredFlatteningParamsResponse response = libraryServiceClient.testOptionalRequiredFlatteningParams(request);
+   * }
+   * 
+ * + * @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 TestOptionalRequiredFlatteningParamsResponse testOptionalRequiredFlatteningParams(TestOptionalRequiredFlatteningParamsRequest request) { + return testOptionalRequiredFlatteningParamsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Test optional flattening parameters of all types + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   int requiredSingularInt32 = 0;
+   *   long requiredSingularInt64 = 0L;
+   *   float requiredSingularFloat = 0.0F;
+   *   double requiredSingularDouble = 0.0;
+   *   boolean requiredSingularBool = false;
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerEnum requiredSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO;
+   *   String requiredSingularString = "";
+   *   ByteString requiredSingularBytes = ByteString.copyFromUtf8("");
+   *   TestOptionalRequiredFlatteningParamsRequest.InnerMessage requiredSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build();
+   *   BookName requiredSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   BookName requiredSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]");
+   *   String requiredSingularResourceNameCommon = "";
+   *   int requiredSingularFixed32 = 0;
+   *   long requiredSingularFixed64 = 0L;
+   *   List<Integer> requiredRepeatedInt32 = new ArrayList<>();
+   *   List<Long> requiredRepeatedInt64 = new ArrayList<>();
+   *   List<Float> requiredRepeatedFloat = new ArrayList<>();
+   *   List<Double> requiredRepeatedDouble = new ArrayList<>();
+   *   List<Boolean> requiredRepeatedBool = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerEnum> requiredRepeatedEnum = new ArrayList<>();
+   *   List<String> requiredRepeatedString = new ArrayList<>();
+   *   List<ByteString> requiredRepeatedBytes = new ArrayList<>();
+   *   List<TestOptionalRequiredFlatteningParamsRequest.InnerMessage> requiredRepeatedMessage = new ArrayList<>();
+   *   List<BookName> requiredRepeatedResourceName = new ArrayList<>();
+   *   List<BookName> requiredRepeatedResourceNameOneof = new ArrayList<>();
+   *   List<String> requiredRepeatedResourceNameCommon = new ArrayList<>();
+   *   List<Integer> requiredRepeatedFixed32 = new ArrayList<>();
+   *   List<Long> requiredRepeatedFixed64 = new ArrayList<>();
+   *   Map<Integer, String> requiredMap = new HashMap<>();
+   *   Any requiredAnyValue = Any.newBuilder().build();
+   *   Struct requiredStructValue = Struct.newBuilder().build();
+   *   Value requiredValueValue = Value.newBuilder().build();
+   *   ListValue requiredListValueValue = ListValue.newBuilder().build();
+   *   Timestamp requiredTimeValue = Timestamp.newBuilder().build();
+   *   Duration requiredDurationValue = Duration.newBuilder().build();
+   *   FieldMask requiredFieldMaskValue = FieldMask.newBuilder().build();
+   *   Int32Value requiredInt32Value = Int32Value.newBuilder().build();
+   *   UInt32Value requiredUint32Value = UInt32Value.newBuilder().build();
+   *   Int64Value requiredInt64Value = Int64Value.newBuilder().build();
+   *   UInt64Value requiredUint64Value = UInt64Value.newBuilder().build();
+   *   FloatValue requiredFloatValue = FloatValue.newBuilder().build();
+   *   DoubleValue requiredDoubleValue = DoubleValue.newBuilder().build();
+   *   StringValue requiredStringValue = StringValue.newBuilder().build();
+   *   BoolValue requiredBoolValue = BoolValue.newBuilder().build();
+   *   BytesValue requiredBytesValue = BytesValue.newBuilder().build();
+   *   List<Any> requiredRepeatedAnyValue = new ArrayList<>();
+   *   List<Struct> requiredRepeatedStructValue = new ArrayList<>();
+   *   List<Value> requiredRepeatedValueValue = new ArrayList<>();
+   *   List<ListValue> requiredRepeatedListValueValue = new ArrayList<>();
+   *   List<Timestamp> requiredRepeatedTimeValue = new ArrayList<>();
+   *   List<Duration> requiredRepeatedDurationValue = new ArrayList<>();
+   *   List<FieldMask> requiredRepeatedFieldMaskValue = new ArrayList<>();
+   *   List<Int32Value> requiredRepeatedInt32Value = new ArrayList<>();
+   *   List<UInt32Value> requiredRepeatedUint32Value = new ArrayList<>();
+   *   List<Int64Value> requiredRepeatedInt64Value = new ArrayList<>();
+   *   List<UInt64Value> requiredRepeatedUint64Value = new ArrayList<>();
+   *   List<FloatValue> requiredRepeatedFloatValue = new ArrayList<>();
+   *   List<DoubleValue> requiredRepeatedDoubleValue = new ArrayList<>();
+   *   List<StringValue> requiredRepeatedStringValue = new ArrayList<>();
+   *   List<BoolValue> requiredRepeatedBoolValue = new ArrayList<>();
+   *   List<BytesValue> requiredRepeatedBytesValue = new ArrayList<>();
+   *   TestOptionalRequiredFlatteningParamsRequest request = TestOptionalRequiredFlatteningParamsRequest.newBuilder()
+   *     .setRequiredSingularInt32(requiredSingularInt32)
+   *     .setRequiredSingularInt64(requiredSingularInt64)
+   *     .setRequiredSingularFloat(requiredSingularFloat)
+   *     .setRequiredSingularDouble(requiredSingularDouble)
+   *     .setRequiredSingularBool(requiredSingularBool)
+   *     .setRequiredSingularEnum(requiredSingularEnum)
+   *     .setRequiredSingularString(requiredSingularString)
+   *     .setRequiredSingularBytes(requiredSingularBytes)
+   *     .setRequiredSingularMessage(requiredSingularMessage)
+   *     .setRequiredSingularResourceName(requiredSingularResourceName.toString())
+   *     .setRequiredSingularResourceNameOneof(requiredSingularResourceNameOneof.toString())
+   *     .setRequiredSingularResourceNameCommon(requiredSingularResourceNameCommon)
+   *     .setRequiredSingularFixed32(requiredSingularFixed32)
+   *     .setRequiredSingularFixed64(requiredSingularFixed64)
+   *     .addAllRequiredRepeatedInt32(requiredRepeatedInt32)
+   *     .addAllRequiredRepeatedInt64(requiredRepeatedInt64)
+   *     .addAllRequiredRepeatedFloat(requiredRepeatedFloat)
+   *     .addAllRequiredRepeatedDouble(requiredRepeatedDouble)
+   *     .addAllRequiredRepeatedBool(requiredRepeatedBool)
+   *     .addAllRequiredRepeatedEnum(requiredRepeatedEnum)
+   *     .addAllRequiredRepeatedString(requiredRepeatedString)
+   *     .addAllRequiredRepeatedBytes(requiredRepeatedBytes)
+   *     .addAllRequiredRepeatedMessage(requiredRepeatedMessage)
+   *     .addAllRequiredRepeatedResourceName(BookName.toStringList(requiredRepeatedResourceName))
+   *     .addAllRequiredRepeatedResourceNameOneof(BookName.toStringList(requiredRepeatedResourceNameOneof))
+   *     .addAllRequiredRepeatedResourceNameCommon(requiredRepeatedResourceNameCommon)
+   *     .addAllRequiredRepeatedFixed32(requiredRepeatedFixed32)
+   *     .addAllRequiredRepeatedFixed64(requiredRepeatedFixed64)
+   *     .putAllRequiredMap(requiredMap)
+   *     .setRequiredAnyValue(requiredAnyValue)
+   *     .setRequiredStructValue(requiredStructValue)
+   *     .setRequiredValueValue(requiredValueValue)
+   *     .setRequiredListValueValue(requiredListValueValue)
+   *     .setRequiredTimeValue(requiredTimeValue)
+   *     .setRequiredDurationValue(requiredDurationValue)
+   *     .setRequiredFieldMaskValue(requiredFieldMaskValue)
+   *     .setRequiredInt32Value(requiredInt32Value)
+   *     .setRequiredUint32Value(requiredUint32Value)
+   *     .setRequiredInt64Value(requiredInt64Value)
+   *     .setRequiredUint64Value(requiredUint64Value)
+   *     .setRequiredFloatValue(requiredFloatValue)
+   *     .setRequiredDoubleValue(requiredDoubleValue)
+   *     .setRequiredStringValue(requiredStringValue)
+   *     .setRequiredBoolValue(requiredBoolValue)
+   *     .setRequiredBytesValue(requiredBytesValue)
+   *     .addAllRequiredRepeatedAnyValue(requiredRepeatedAnyValue)
+   *     .addAllRequiredRepeatedStructValue(requiredRepeatedStructValue)
+   *     .addAllRequiredRepeatedValueValue(requiredRepeatedValueValue)
+   *     .addAllRequiredRepeatedListValueValue(requiredRepeatedListValueValue)
+   *     .addAllRequiredRepeatedTimeValue(requiredRepeatedTimeValue)
+   *     .addAllRequiredRepeatedDurationValue(requiredRepeatedDurationValue)
+   *     .addAllRequiredRepeatedFieldMaskValue(requiredRepeatedFieldMaskValue)
+   *     .addAllRequiredRepeatedInt32Value(requiredRepeatedInt32Value)
+   *     .addAllRequiredRepeatedUint32Value(requiredRepeatedUint32Value)
+   *     .addAllRequiredRepeatedInt64Value(requiredRepeatedInt64Value)
+   *     .addAllRequiredRepeatedUint64Value(requiredRepeatedUint64Value)
+   *     .addAllRequiredRepeatedFloatValue(requiredRepeatedFloatValue)
+   *     .addAllRequiredRepeatedDoubleValue(requiredRepeatedDoubleValue)
+   *     .addAllRequiredRepeatedStringValue(requiredRepeatedStringValue)
+   *     .addAllRequiredRepeatedBoolValue(requiredRepeatedBoolValue)
+   *     .addAllRequiredRepeatedBytesValue(requiredRepeatedBytesValue)
+   *     .build();
+   *   ApiFuture<TestOptionalRequiredFlatteningParamsResponse> future = libraryServiceClient.testOptionalRequiredFlatteningParamsCallable().futureCall(request);
+   *   // Do something
+   *   TestOptionalRequiredFlatteningParamsResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable testOptionalRequiredFlatteningParamsCallable() { + return stub.testOptionalRequiredFlatteningParamsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * This method is not exposed in the GAPIC config. It should be generated. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *
+   *   Book response = libraryServiceClient.privateListShelves();
+   * }
+   * 
+ * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Book privateListShelves() { + ListShelvesRequest request = + ListShelvesRequest.newBuilder().build(); + return privateListShelves(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * This method is not exposed in the GAPIC config. It should be generated. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ListShelvesRequest request = ListShelvesRequest.newBuilder().build();
+   *   Book response = libraryServiceClient.privateListShelves(request);
+   * }
+   * 
+ * + * @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 Book privateListShelves(ListShelvesRequest request) { + return privateListShelvesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * This method is not exposed in the GAPIC config. It should be generated. + * + * Sample code: + *

+   * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+   *   ListShelvesRequest request = ListShelvesRequest.newBuilder().build();
+   *   ApiFuture<Book> future = libraryServiceClient.privateListShelvesCallable().futureCall(request);
+   *   // Do something
+   *   Book response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable privateListShelvesCallable() { + return stub.privateListShelvesCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListBooksPagedResponse extends AbstractPagedListResponse< + ListBooksRequest, + ListBooksResponse, + Book, + ListBooksPage, + ListBooksFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListBooksPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListBooksPagedResponse apply(ListBooksPage input) { + return new ListBooksPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListBooksPagedResponse(ListBooksPage page) { + super(page, ListBooksFixedSizeCollection.createEmptyCollection()); + } + + + } + + public static class ListBooksPage extends AbstractPage< + ListBooksRequest, + ListBooksResponse, + Book, + ListBooksPage> { + + private ListBooksPage( + PageContext context, + ListBooksResponse response) { + super(context, response); + } + + private static ListBooksPage createEmptyPage() { + return new ListBooksPage(null, null); + } + + @Override + protected ListBooksPage createPage( + PageContext context, + ListBooksResponse response) { + return new ListBooksPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + + + + + } + + public static class ListBooksFixedSizeCollection extends AbstractFixedSizeCollection< + ListBooksRequest, + ListBooksResponse, + Book, + ListBooksPage, + ListBooksFixedSizeCollection> { + + private ListBooksFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListBooksFixedSizeCollection createEmptyCollection() { + return new ListBooksFixedSizeCollection(null, 0); + } + + @Override + protected ListBooksFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListBooksFixedSizeCollection(pages, collectionSize); + } + + + } + public static class ListStringsPagedResponse extends AbstractPagedListResponse< + ListStringsRequest, + ListStringsResponse, + String, + ListStringsPage, + ListStringsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListStringsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListStringsPagedResponse apply(ListStringsPage input) { + return new ListStringsPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListStringsPagedResponse(ListStringsPage page) { + super(page, ListStringsFixedSizeCollection.createEmptyCollection()); + } + public Iterable iterateAllAsResourceName() { + return Iterables.transform(iterateAll(), new Function() { + @Override + public ResourceName apply(String arg0) { + return UntypedResourceName.parse(arg0); + } + } + ); + } + + } + + public static class ListStringsPage extends AbstractPage< + ListStringsRequest, + ListStringsResponse, + String, + ListStringsPage> { + + private ListStringsPage( + PageContext context, + ListStringsResponse response) { + super(context, response); + } + + private static ListStringsPage createEmptyPage() { + return new ListStringsPage(null, null); + } + + @Override + protected ListStringsPage createPage( + PageContext context, + ListStringsResponse response) { + return new ListStringsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + public Iterable iterateAllAsResourceName() { + return Iterables.transform(iterateAll(), new Function() { + @Override + public ResourceName apply(String arg0) { + return UntypedResourceName.parse(arg0); + } + } + ); + } + + public Iterable getValuesAsResourceName() { + return Iterables.transform(getValues(), new Function() { + @Override + public ResourceName apply(String arg0) { + return UntypedResourceName.parse(arg0); + } + } + ); + } + + } + + public static class ListStringsFixedSizeCollection extends AbstractFixedSizeCollection< + ListStringsRequest, + ListStringsResponse, + String, + ListStringsPage, + ListStringsFixedSizeCollection> { + + private ListStringsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListStringsFixedSizeCollection createEmptyCollection() { + return new ListStringsFixedSizeCollection(null, 0); + } + + @Override + protected ListStringsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListStringsFixedSizeCollection(pages, collectionSize); + } + public Iterable getValuesAsResourceName() { + return Iterables.transform(getValues(), new Function() { + @Override + public ResourceName apply(String arg0) { + return UntypedResourceName.parse(arg0); + } + } + ); + } + + } + public static class FindRelatedBooksPagedResponse extends AbstractPagedListResponse< + FindRelatedBooksRequest, + FindRelatedBooksResponse, + String, + FindRelatedBooksPage, + FindRelatedBooksFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + FindRelatedBooksPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public FindRelatedBooksPagedResponse apply(FindRelatedBooksPage input) { + return new FindRelatedBooksPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private FindRelatedBooksPagedResponse(FindRelatedBooksPage page) { + super(page, FindRelatedBooksFixedSizeCollection.createEmptyCollection()); + } + public Iterable iterateAllAsBookName() { + return Iterables.transform(iterateAll(), new Function() { + @Override + public BookName apply(String arg0) { + return BookName.parse(arg0); + } + } + ); + } + + } + + public static class FindRelatedBooksPage extends AbstractPage< + FindRelatedBooksRequest, + FindRelatedBooksResponse, + String, + FindRelatedBooksPage> { + + private FindRelatedBooksPage( + PageContext context, + FindRelatedBooksResponse response) { + super(context, response); + } + + private static FindRelatedBooksPage createEmptyPage() { + return new FindRelatedBooksPage(null, null); + } + + @Override + protected FindRelatedBooksPage createPage( + PageContext context, + FindRelatedBooksResponse response) { + return new FindRelatedBooksPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + public Iterable iterateAllAsBookName() { + return Iterables.transform(iterateAll(), new Function() { + @Override + public BookName apply(String arg0) { + return BookName.parse(arg0); + } + } + ); + } + + public Iterable getValuesAsBookName() { + return Iterables.transform(getValues(), new Function() { + @Override + public BookName apply(String arg0) { + return BookName.parse(arg0); + } + } + ); + } + + } + + public static class FindRelatedBooksFixedSizeCollection extends AbstractFixedSizeCollection< + FindRelatedBooksRequest, + FindRelatedBooksResponse, + String, + FindRelatedBooksPage, + FindRelatedBooksFixedSizeCollection> { + + private FindRelatedBooksFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static FindRelatedBooksFixedSizeCollection createEmptyCollection() { + return new FindRelatedBooksFixedSizeCollection(null, 0); + } + + @Override + protected FindRelatedBooksFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new FindRelatedBooksFixedSizeCollection(pages, collectionSize); + } + public Iterable getValuesAsBookName() { + return Iterables.transform(getValues(), new Function() { + @Override + public BookName apply(String arg0) { + return BookName.parse(arg0); + } + } + ); + } + + } +} +============== file: src/main/java/com/google/example/library/v1/LibraryServiceSettings.java ============== +/* + * 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.example.library.v1; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.longrunning.OperationFuture; +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.ClientSettings; +import com.google.api.gax.rpc.HeaderProvider; +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.ServerStreamingCallSettings; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StreamingCallSettings; +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.auth.Credentials; +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.common.collect.Sets; +import static com.google.example.library.v1.LibraryServiceClient.FindRelatedBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListStringsPagedResponse; +import com.google.example.library.v1.stub.LibraryServiceStubSettings; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.tagger.v1.TaggerProto.AddTagRequest; +import com.google.tagger.v1.TaggerProto.AddTagResponse; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link LibraryServiceClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (library-example.googleapis.com) and default port (1234) + * are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. + * When build() is called, the tree of builders is called to create the complete settings + * object. + * + * For example, to set the total timeout of createShelf to 30 seconds: + * + *

+ * 
+ * LibraryServiceSettings.Builder libraryServiceSettingsBuilder =
+ *     LibraryServiceSettings.newBuilder();
+ * libraryServiceSettingsBuilder
+ *     .createShelfSettings()
+ *     .setRetrySettings(
+ *         libraryServiceSettingsBuilder.createShelfSettings().getRetrySettings().toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * LibraryServiceSettings libraryServiceSettings = libraryServiceSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class LibraryServiceSettings extends ClientSettings { + /** + * Returns the object with the settings used for calls to createShelf. + */ + public UnaryCallSettings createShelfSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).createShelfSettings(); + } + + /** + * Returns the object with the settings used for calls to getShelf. + */ + public UnaryCallSettings getShelfSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getShelfSettings(); + } + + /** + * Returns the object with the settings used for calls to listShelves. + */ + public UnaryCallSettings listShelvesSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).listShelvesSettings(); + } + + /** + * Returns the object with the settings used for calls to deleteShelf. + */ + public UnaryCallSettings deleteShelfSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).deleteShelfSettings(); + } + + /** + * Returns the object with the settings used for calls to mergeShelves. + */ + public UnaryCallSettings mergeShelvesSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).mergeShelvesSettings(); + } + + /** + * Returns the object with the settings used for calls to createBook. + */ + public UnaryCallSettings createBookSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).createBookSettings(); + } + + /** + * Returns the object with the settings used for calls to publishSeries. + */ + public UnaryCallSettings publishSeriesSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).publishSeriesSettings(); + } + + /** + * Returns the object with the settings used for calls to createInventory. + */ + public UnaryCallSettings createInventorySettings() { + return ((LibraryServiceStubSettings) getStubSettings()).createInventorySettings(); + } + + /** + * Returns the object with the settings used for calls to getBook. + */ + public UnaryCallSettings getBookSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getBookSettings(); + } + + /** + * Returns the object with the settings used for calls to listBooks. + */ + public PagedCallSettings listBooksSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).listBooksSettings(); + } + + /** + * Returns the object with the settings used for calls to deleteBook. + */ + public UnaryCallSettings deleteBookSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).deleteBookSettings(); + } + + /** + * Returns the object with the settings used for calls to updateBook. + */ + public UnaryCallSettings updateBookSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).updateBookSettings(); + } + + /** + * Returns the object with the settings used for calls to moveBook. + */ + public UnaryCallSettings moveBookSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).moveBookSettings(); + } + + /** + * Returns the object with the settings used for calls to listStrings. + */ + public PagedCallSettings listStringsSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).listStringsSettings(); + } + + /** + * Returns the object with the settings used for calls to addComments. + */ + public UnaryCallSettings addCommentsSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).addCommentsSettings(); + } + + /** + * Returns the object with the settings used for calls to getBookFromArchive. + */ + public UnaryCallSettings getBookFromArchiveSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getBookFromArchiveSettings(); + } + + /** + * Returns the object with the settings used for calls to getBookFromAnywhere. + */ + public UnaryCallSettings getBookFromAnywhereSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getBookFromAnywhereSettings(); + } + + /** + * Returns the object with the settings used for calls to getBookFromAbsolutelyAnywhere. + */ + public UnaryCallSettings getBookFromAbsolutelyAnywhereSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getBookFromAbsolutelyAnywhereSettings(); + } + + /** + * Returns the object with the settings used for calls to updateBookIndex. + */ + public UnaryCallSettings updateBookIndexSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).updateBookIndexSettings(); + } + + /** + * Returns the object with the settings used for calls to findRelatedBooks. + */ + public PagedCallSettings findRelatedBooksSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).findRelatedBooksSettings(); + } + + /** + * Returns the object with the settings used for calls to addTag. + */ + public UnaryCallSettings addTagSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).addTagSettings(); + } + + /** + * Returns the object with the settings used for calls to getBigBook. + */ + public UnaryCallSettings getBigBookSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getBigBookSettings(); + } + + /** + * Returns the object with the settings used for calls to getBigBook. + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings getBigBookOperationSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getBigBookOperationSettings(); + } + + /** + * Returns the object with the settings used for calls to getBigNothing. + */ + public UnaryCallSettings getBigNothingSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getBigNothingSettings(); + } + + /** + * Returns the object with the settings used for calls to getBigNothing. + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings getBigNothingOperationSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).getBigNothingOperationSettings(); + } + + /** + * Returns the object with the settings used for calls to moveBooks. + */ + public UnaryCallSettings moveBooksSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).moveBooksSettings(); + } + + /** + * Returns the object with the settings used for calls to archiveBooks. + */ + public UnaryCallSettings archiveBooksSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).archiveBooksSettings(); + } + + /** + * Returns the object with the settings used for calls to longRunningArchiveBooks. + */ + public UnaryCallSettings longRunningArchiveBooksSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).longRunningArchiveBooksSettings(); + } + + /** + * Returns the object with the settings used for calls to longRunningArchiveBooks. + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings longRunningArchiveBooksOperationSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).longRunningArchiveBooksOperationSettings(); + } + + /** + * Returns the object with the settings used for calls to saveBook. + */ + public UnaryCallSettings saveBookSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).saveBookSettings(); + } + + /** + * Returns the object with the settings used for calls to testOptionalRequiredFlatteningParams. + */ + public UnaryCallSettings testOptionalRequiredFlatteningParamsSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).testOptionalRequiredFlatteningParamsSettings(); + } + + /** + * Returns the object with the settings used for calls to privateListShelves. + */ + public UnaryCallSettings privateListShelvesSettings() { + return ((LibraryServiceStubSettings) getStubSettings()).privateListShelvesSettings(); + } + + + public static final LibraryServiceSettings create(LibraryServiceStubSettings stub) throws IOException { + return new LibraryServiceSettings.Builder(stub.toBuilder()).build(); + } + + /** + * Returns a builder for the default ExecutorProvider for this service. + */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return LibraryServiceStubSettings.defaultExecutorProviderBuilder(); + } + + /** + * Returns the default service endpoint. + */ + public static String getDefaultEndpoint() { + return LibraryServiceStubSettings.getDefaultEndpoint(); + } + /** + * Returns the default service port. + */ + public static int getDefaultServicePort() { + return LibraryServiceStubSettings.getDefaultServicePort(); + } + + + /** + * Returns the default service scopes. + */ + public static List getDefaultServiceScopes() { + return LibraryServiceStubSettings.getDefaultServiceScopes(); + } + + + /** + * Returns a builder for the default credentials for this service. + */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return LibraryServiceStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder() { + return LibraryServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return LibraryServiceStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return LibraryServiceStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** + * Returns a new builder for this class. + */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** + * Returns a new builder for this class. + */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** + * Returns a builder containing all the values of this settings class. + */ + public Builder toBuilder() { + return new Builder(this); + } + + protected LibraryServiceSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** + * Builder for LibraryServiceSettings. + */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(LibraryServiceStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(LibraryServiceStubSettings.newBuilder()); + } + + protected Builder(LibraryServiceSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(LibraryServiceStubSettings.Builder stubSettings) { + super(stubSettings); + } + + + public LibraryServiceStubSettings.Builder getStubSettingsBuilder() { + return ((LibraryServiceStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + * Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods(ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** + * Returns the builder for the settings used for calls to createShelf. + */ + public UnaryCallSettings.Builder createShelfSettings() { + return getStubSettingsBuilder().createShelfSettings(); + } + + /** + * Returns the builder for the settings used for calls to getShelf. + */ + public UnaryCallSettings.Builder getShelfSettings() { + return getStubSettingsBuilder().getShelfSettings(); + } + + /** + * Returns the builder for the settings used for calls to listShelves. + */ + public UnaryCallSettings.Builder listShelvesSettings() { + return getStubSettingsBuilder().listShelvesSettings(); + } + + /** + * Returns the builder for the settings used for calls to deleteShelf. + */ + public UnaryCallSettings.Builder deleteShelfSettings() { + return getStubSettingsBuilder().deleteShelfSettings(); + } + + /** + * Returns the builder for the settings used for calls to mergeShelves. + */ + public UnaryCallSettings.Builder mergeShelvesSettings() { + return getStubSettingsBuilder().mergeShelvesSettings(); + } + + /** + * Returns the builder for the settings used for calls to createBook. + */ + public UnaryCallSettings.Builder createBookSettings() { + return getStubSettingsBuilder().createBookSettings(); + } + + /** + * Returns the builder for the settings used for calls to publishSeries. + */ + public UnaryCallSettings.Builder publishSeriesSettings() { + return getStubSettingsBuilder().publishSeriesSettings(); + } + + /** + * Returns the builder for the settings used for calls to createInventory. + */ + public UnaryCallSettings.Builder createInventorySettings() { + return getStubSettingsBuilder().createInventorySettings(); + } + + /** + * Returns the builder for the settings used for calls to getBook. + */ + public UnaryCallSettings.Builder getBookSettings() { + return getStubSettingsBuilder().getBookSettings(); + } + + /** + * Returns the builder for the settings used for calls to listBooks. + */ + public PagedCallSettings.Builder listBooksSettings() { + return getStubSettingsBuilder().listBooksSettings(); + } + + /** + * Returns the builder for the settings used for calls to deleteBook. + */ + public UnaryCallSettings.Builder deleteBookSettings() { + return getStubSettingsBuilder().deleteBookSettings(); + } + + /** + * Returns the builder for the settings used for calls to updateBook. + */ + public UnaryCallSettings.Builder updateBookSettings() { + return getStubSettingsBuilder().updateBookSettings(); + } + + /** + * Returns the builder for the settings used for calls to moveBook. + */ + public UnaryCallSettings.Builder moveBookSettings() { + return getStubSettingsBuilder().moveBookSettings(); + } + + /** + * Returns the builder for the settings used for calls to listStrings. + */ + public PagedCallSettings.Builder listStringsSettings() { + return getStubSettingsBuilder().listStringsSettings(); + } + + /** + * Returns the builder for the settings used for calls to addComments. + */ + public UnaryCallSettings.Builder addCommentsSettings() { + return getStubSettingsBuilder().addCommentsSettings(); + } + + /** + * Returns the builder for the settings used for calls to getBookFromArchive. + */ + public UnaryCallSettings.Builder getBookFromArchiveSettings() { + return getStubSettingsBuilder().getBookFromArchiveSettings(); + } + + /** + * Returns the builder for the settings used for calls to getBookFromAnywhere. + */ + public UnaryCallSettings.Builder getBookFromAnywhereSettings() { + return getStubSettingsBuilder().getBookFromAnywhereSettings(); + } + + /** + * Returns the builder for the settings used for calls to getBookFromAbsolutelyAnywhere. + */ + public UnaryCallSettings.Builder getBookFromAbsolutelyAnywhereSettings() { + return getStubSettingsBuilder().getBookFromAbsolutelyAnywhereSettings(); + } + + /** + * Returns the builder for the settings used for calls to updateBookIndex. + */ + public UnaryCallSettings.Builder updateBookIndexSettings() { + return getStubSettingsBuilder().updateBookIndexSettings(); + } + + /** + * Returns the builder for the settings used for calls to findRelatedBooks. + */ + public PagedCallSettings.Builder findRelatedBooksSettings() { + return getStubSettingsBuilder().findRelatedBooksSettings(); + } + + /** + * Returns the builder for the settings used for calls to addTag. + */ + public UnaryCallSettings.Builder addTagSettings() { + return getStubSettingsBuilder().addTagSettings(); + } + + /** + * Returns the builder for the settings used for calls to getBigBook. + */ + public UnaryCallSettings.Builder getBigBookSettings() { + return getStubSettingsBuilder().getBigBookSettings(); + } + + /** + * Returns the builder for the settings used for calls to getBigBook. + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder getBigBookOperationSettings() { + return getStubSettingsBuilder().getBigBookOperationSettings(); + } + + /** + * Returns the builder for the settings used for calls to getBigNothing. + */ + public UnaryCallSettings.Builder getBigNothingSettings() { + return getStubSettingsBuilder().getBigNothingSettings(); + } + + /** + * Returns the builder for the settings used for calls to getBigNothing. + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder getBigNothingOperationSettings() { + return getStubSettingsBuilder().getBigNothingOperationSettings(); + } + + /** + * Returns the builder for the settings used for calls to moveBooks. + */ + public UnaryCallSettings.Builder moveBooksSettings() { + return getStubSettingsBuilder().moveBooksSettings(); + } + + /** + * Returns the builder for the settings used for calls to archiveBooks. + */ + public UnaryCallSettings.Builder archiveBooksSettings() { + return getStubSettingsBuilder().archiveBooksSettings(); + } + + /** + * Returns the builder for the settings used for calls to longRunningArchiveBooks. + */ + public UnaryCallSettings.Builder longRunningArchiveBooksSettings() { + return getStubSettingsBuilder().longRunningArchiveBooksSettings(); + } + + /** + * Returns the builder for the settings used for calls to longRunningArchiveBooks. + */ + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + public OperationCallSettings.Builder longRunningArchiveBooksOperationSettings() { + return getStubSettingsBuilder().longRunningArchiveBooksOperationSettings(); + } + + /** + * Returns the builder for the settings used for calls to saveBook. + */ + public UnaryCallSettings.Builder saveBookSettings() { + return getStubSettingsBuilder().saveBookSettings(); + } + + /** + * Returns the builder for the settings used for calls to testOptionalRequiredFlatteningParams. + */ + public UnaryCallSettings.Builder testOptionalRequiredFlatteningParamsSettings() { + return getStubSettingsBuilder().testOptionalRequiredFlatteningParamsSettings(); + } + + /** + * Returns the builder for the settings used for calls to privateListShelves. + */ + public UnaryCallSettings.Builder privateListShelvesSettings() { + return getStubSettingsBuilder().privateListShelvesSettings(); + } + + @Override + public LibraryServiceSettings build() throws IOException { + return new LibraryServiceSettings(this); + } + } +} +============== file: src/main/java/com/google/example/library/v1/MyProtoClient.java ============== +/* + * 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.example.library.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.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.paging.FixedSizeCollection; +import com.google.api.gax.paging.Page; +import com.google.api.gax.rpc.ApiExceptions; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.common.base.Function; +import com.google.common.collect.Iterables; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.example.library.v1.stub.MyProtoStub; +import com.google.example.library.v1.stub.MyProtoStubSettings; +import com.google.protos.google.example.library.v1.AnotherService.MethodRequest; +import com.google.protos.google.example.library.v1.AnotherService.MethodResponse; +import com.google.protos.google.example.library.v1.AnotherService.Namespace; +import java.io.Closeable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND SERVICE +/** + * Service Description: + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

+ * 
+ * try (MyProtoClient myProtoClient = MyProtoClient.create()) {
+ *   MethodRequest request = MethodRequest.newBuilder().build();
+ *   MethodResponse response = myProtoClient.myMethod(request);
+ * }
+ * 
+ * 
+ * + *

Note: close() needs to be called on the myProtoClient object to clean up resources such + * as threads. In the example above, try-with-resources is used, which automatically calls + * close(). + * + *

The surface of this class includes several types of Java methods for each of the API's methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available + * as parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request + * object, which must be constructed before the call. Not every API method will have a request + * object method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable + * API callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist + * with these names, this class includes a format method for each type of name, and additionally + * a parse method to extract the individual identifiers contained within names that are + * returned. + * + *

This class can be customized by passing in a custom instance of MyProtoSettings to + * create(). For example: + * + * To customize credentials: + * + *

+ * 
+ * MyProtoSettings myProtoSettings =
+ *     MyProtoSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * MyProtoClient myProtoClient =
+ *     MyProtoClient.create(myProtoSettings);
+ * 
+ * 
+ * + * To customize the endpoint: + * + *
+ * 
+ * MyProtoSettings myProtoSettings =
+ *     MyProtoSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * MyProtoClient myProtoClient =
+ *     MyProtoClient.create(myProtoSettings);
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class MyProtoClient implements BackgroundResource { + private final MyProtoSettings settings; + private final MyProtoStub stub; + + + + /** + * Constructs an instance of MyProtoClient with default settings. + */ + public static final MyProtoClient create() throws IOException { + return create(MyProtoSettings.newBuilder().build()); + } + + /** + * Constructs an instance of MyProtoClient, using the given settings. + * The channels are created based on the settings passed in, or defaults for any + * settings that are not set. + */ + public static final MyProtoClient create(MyProtoSettings settings) throws IOException { + return new MyProtoClient(settings); + } + + /** + * Constructs an instance of MyProtoClient, using the given stub for making calls. This is for + * advanced usage - prefer to use MyProtoSettings}. + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final MyProtoClient create(MyProtoStub stub) { + return new MyProtoClient(stub); + } + + /** + * Constructs an instance of MyProtoClient, using the given settings. + * This is protected so that it is easy to make a subclass, but otherwise, the static + * factory methods should be preferred. + */ + protected MyProtoClient(MyProtoSettings settings) throws IOException { + this.settings = settings; + this.stub = ((MyProtoStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected MyProtoClient(MyProtoStub stub) { + this.settings = null; + this.stub = stub; + } + + public final MyProtoSettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public MyProtoStub getStub() { + return stub; + } + + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (MyProtoClient myProtoClient = MyProtoClient.create()) {
+   *   MethodRequest request = MethodRequest.newBuilder().build();
+   *   MethodResponse response = myProtoClient.myMethod(request);
+   * }
+   * 
+ * + * @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 MethodResponse myMethod(MethodRequest request) { + return myMethodCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * + * + * Sample code: + *

+   * try (MyProtoClient myProtoClient = MyProtoClient.create()) {
+   *   MethodRequest request = MethodRequest.newBuilder().build();
+   *   ApiFuture<MethodResponse> future = myProtoClient.myMethodCallable().futureCall(request);
+   *   // Do something
+   *   MethodResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable myMethodCallable() { + return stub.myMethodCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Define a service with a reserved name + * + * Sample code: + *

+   * try (MyProtoClient myProtoClient = MyProtoClient.create()) {
+   *   MethodRequest request = MethodRequest.newBuilder().build();
+   *   Namespace response = myProtoClient.getNamespace(request);
+   * }
+   * 
+ * + * @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 Namespace getNamespace(MethodRequest request) { + return getNamespaceCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Define a service with a reserved name + * + * Sample code: + *

+   * try (MyProtoClient myProtoClient = MyProtoClient.create()) {
+   *   MethodRequest request = MethodRequest.newBuilder().build();
+   *   ApiFuture<Namespace> future = myProtoClient.getNamespaceCallable().futureCall(request);
+   *   // Do something
+   *   Namespace response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable getNamespaceCallable() { + return stub.getNamespaceCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + +} +============== file: src/main/java/com/google/example/library/v1/MyProtoSettings.java ============== +/* + * 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.example.library.v1; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.HeaderProvider; +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.auth.Credentials; +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.common.collect.Sets; +import com.google.example.library.v1.stub.MyProtoStubSettings; +import com.google.protos.google.example.library.v1.AnotherService.MethodRequest; +import com.google.protos.google.example.library.v1.AnotherService.MethodResponse; +import com.google.protos.google.example.library.v1.AnotherService.Namespace; +import com.google.protos.google.example.library.v1.MyProtoGrpc; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link MyProtoClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (library-example.googleapis.com) and default port (1234) + * are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. + * When build() is called, the tree of builders is called to create the complete settings + * object. + * + * For example, to set the total timeout of myMethod to 30 seconds: + * + *

+ * 
+ * MyProtoSettings.Builder myProtoSettingsBuilder =
+ *     MyProtoSettings.newBuilder();
+ * myProtoSettingsBuilder
+ *     .myMethodSettings()
+ *     .setRetrySettings(
+ *         myProtoSettingsBuilder.myMethodSettings().getRetrySettings().toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * MyProtoSettings myProtoSettings = myProtoSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class MyProtoSettings extends ClientSettings { + /** + * Returns the object with the settings used for calls to myMethod. + */ + public UnaryCallSettings myMethodSettings() { + return ((MyProtoStubSettings) getStubSettings()).myMethodSettings(); + } + + /** + * Returns the object with the settings used for calls to getNamespace. + */ + public UnaryCallSettings getNamespaceSettings() { + return ((MyProtoStubSettings) getStubSettings()).getNamespaceSettings(); + } + + + public static final MyProtoSettings create(MyProtoStubSettings stub) throws IOException { + return new MyProtoSettings.Builder(stub.toBuilder()).build(); + } + + /** + * Returns a builder for the default ExecutorProvider for this service. + */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return MyProtoStubSettings.defaultExecutorProviderBuilder(); + } + + /** + * Returns the default service endpoint. + */ + public static String getDefaultEndpoint() { + return MyProtoStubSettings.getDefaultEndpoint(); + } + /** + * Returns the default service port. + */ + public static int getDefaultServicePort() { + return MyProtoStubSettings.getDefaultServicePort(); + } + + + /** + * Returns the default service scopes. + */ + public static List getDefaultServiceScopes() { + return MyProtoStubSettings.getDefaultServiceScopes(); + } + + + /** + * Returns a builder for the default credentials for this service. + */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return MyProtoStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder() { + return MyProtoStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return MyProtoStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return MyProtoStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** + * Returns a new builder for this class. + */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** + * Returns a new builder for this class. + */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** + * Returns a builder containing all the values of this settings class. + */ + public Builder toBuilder() { + return new Builder(this); + } + + protected MyProtoSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** + * Builder for MyProtoSettings. + */ + public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(MyProtoStubSettings.newBuilder(clientContext)); + } + + private static Builder createDefault() { + return new Builder(MyProtoStubSettings.newBuilder()); + } + + protected Builder(MyProtoSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(MyProtoStubSettings.Builder stubSettings) { + super(stubSettings); + } + + + public MyProtoStubSettings.Builder getStubSettingsBuilder() { + return ((MyProtoStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + * Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods(ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** + * Returns the builder for the settings used for calls to myMethod. + */ + public UnaryCallSettings.Builder myMethodSettings() { + return getStubSettingsBuilder().myMethodSettings(); + } + + /** + * Returns the builder for the settings used for calls to getNamespace. + */ + public UnaryCallSettings.Builder getNamespaceSettings() { + return getStubSettingsBuilder().getNamespaceSettings(); + } + + @Override + public MyProtoSettings build() throws IOException { + return new MyProtoSettings(this); + } + } +} +============== file: src/main/java/com/google/example/library/v1/package-info.java ============== +/* + * 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. + */ + +/** + * A client to Google Example Library API. + * + * The interfaces provided are listed below, along with usage samples. + * + * ==================== + * LibraryServiceClient + * ==================== + * + * Service Description: This API represents a simple digital library. It lets you manage Shelf + * resources and Book resources in the library. It defines the following + * resource model: + * + * - The API has a collection of [Shelf][google.example.library.v1.Shelf] + * resources, named ``bookShelves/*`` + * + * - Each Shelf has a collection of [Book][google.example.library.v1.Book] + * resources, named `bookShelves/*/books/*` + * + * Check out [cloud docs!](/library/example/link). + * This is [not a cloud link](http://www.google.com). + * + * Service comment may include special characters: <>&"`'{@literal @}. + * + * Sample for LibraryServiceClient: + *
+ * 
+ * try (LibraryServiceClient libraryServiceClient = LibraryServiceClient.create()) {
+ *   Shelf shelf = Shelf.newBuilder().build();
+ *   Shelf response = libraryServiceClient.createShelf(shelf);
+ * }
+ * 
+ * 
+ * + * ============= + * MyProtoClient + * ============= + * + * Service Description: + * + * Sample for MyProtoClient: + *
+ * 
+ * try (MyProtoClient myProtoClient = MyProtoClient.create()) {
+ *   MethodRequest request = MethodRequest.newBuilder().build();
+ *   MethodResponse response = myProtoClient.myMethod(request);
+ * }
+ * 
+ * 
+ * + */ +@Generated("by gapic-generator") +package com.google.example.library.v1; + +import javax.annotation.Generated; +============== file: src/main/java/com/google/example/library/v1/stub/HttpJsonLibraryServiceCallableFactory.java ============== +/* + * 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.example.library.v1.stub; + +import com.google.api.client.http.HttpMethods; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMessage; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.FieldsExtractor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.longrunning.OperationSnapshot; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.RequestParamsExtractor; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import com.google.example.library.v1.AddCommentsRequest; +import com.google.example.library.v1.ArchiveBooksMetadata; +import com.google.example.library.v1.ArchiveBooksRequest; +import com.google.example.library.v1.ArchiveBooksResponse; +import com.google.example.library.v1.ArchiveName; +import com.google.example.library.v1.ArchivedBookName; +import com.google.example.library.v1.Book; +import com.google.example.library.v1.BookFromAnywhere; +import com.google.example.library.v1.BookFromArchive; +import com.google.example.library.v1.BookName; +import com.google.example.library.v1.Comment; +import com.google.example.library.v1.CreateBookRequest; +import com.google.example.library.v1.CreateInventoryRequest; +import com.google.example.library.v1.CreateShelfRequest; +import com.google.example.library.v1.DeleteBookRequest; +import com.google.example.library.v1.DeleteShelfRequest; +import com.google.example.library.v1.FindRelatedBooksRequest; +import com.google.example.library.v1.FindRelatedBooksResponse; +import com.google.example.library.v1.FolderName; +import com.google.example.library.v1.GetBigBookMetadata; +import com.google.example.library.v1.GetBookFromAbsolutelyAnywhereRequest; +import com.google.example.library.v1.GetBookFromAnywhereRequest; +import com.google.example.library.v1.GetBookFromArchiveRequest; +import com.google.example.library.v1.GetBookRequest; +import com.google.example.library.v1.GetShelfRequest; +import com.google.example.library.v1.Inventory; +import com.google.example.library.v1.InventoryName; +import static com.google.example.library.v1.LibraryServiceClient.FindRelatedBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListStringsPagedResponse; +import com.google.example.library.v1.LibraryServiceSettings; +import com.google.example.library.v1.ListBooksRequest; +import com.google.example.library.v1.ListBooksResponse; +import com.google.example.library.v1.ListShelvesRequest; +import com.google.example.library.v1.ListShelvesResponse; +import com.google.example.library.v1.ListStringsRequest; +import com.google.example.library.v1.ListStringsResponse; +import com.google.example.library.v1.LocationName; +import com.google.example.library.v1.MergeShelvesRequest; +import com.google.example.library.v1.MoveBookRequest; +import com.google.example.library.v1.MoveBooksRequest; +import com.google.example.library.v1.MoveBooksResponse; +import com.google.example.library.v1.ProjectName; +import com.google.example.library.v1.PublishSeriesRequest; +import com.google.example.library.v1.PublishSeriesResponse; +import com.google.example.library.v1.PublisherName; +import com.google.example.library.v1.SeriesUuid; +import com.google.example.library.v1.Shelf; +import com.google.example.library.v1.ShelfName; +import com.google.example.library.v1.SomeMessage; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest.InnerMessage; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsResponse; +import com.google.example.library.v1.UpdateBookIndexRequest; +import com.google.example.library.v1.UpdateBookRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.BoolValue; +import com.google.protobuf.ByteString; +import com.google.protobuf.BytesValue; +import com.google.protobuf.DoubleValue; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.FloatValue; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Int64Value; +import com.google.protobuf.ListValue; +import com.google.protobuf.StringValue; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; +import com.google.protobuf.UInt32Value; +import com.google.protobuf.UInt64Value; +import com.google.protobuf.Value; +import com.google.tagger.v1.TaggerProto.AddTagRequest; +import com.google.tagger.v1.TaggerProto.AddTagResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * REST callable factory implementation for Google Example Library API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class HttpJsonLibraryServiceCallableFactory implements HttpJsonStubCallableFactory< + ApiMessage, BackgroundResource> { + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable(httpJsonCallSettings, callSettings, clientContext); + } + + + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + @Override + @Nullable + public OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, BackgroundResource operationsStub) { + return null; + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable(httpJsonCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable(httpJsonCallSettings, batchingCallSettings, clientContext); + } +} +============== file: src/main/java/com/google/example/library/v1/stub/HttpJsonLibraryServiceStub.java ============== +/* + * 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.example.library.v1.stub; + +import com.google.api.client.http.HttpMethods; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.FieldsExtractor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.longrunning.OperationSnapshot; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.RequestParamsExtractor; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import com.google.example.library.v1.AddCommentsRequest; +import com.google.example.library.v1.ArchiveBooksMetadata; +import com.google.example.library.v1.ArchiveBooksRequest; +import com.google.example.library.v1.ArchiveBooksResponse; +import com.google.example.library.v1.ArchiveName; +import com.google.example.library.v1.ArchivedBookName; +import com.google.example.library.v1.Book; +import com.google.example.library.v1.BookFromAnywhere; +import com.google.example.library.v1.BookFromArchive; +import com.google.example.library.v1.BookName; +import com.google.example.library.v1.Comment; +import com.google.example.library.v1.CreateBookRequest; +import com.google.example.library.v1.CreateInventoryRequest; +import com.google.example.library.v1.CreateShelfRequest; +import com.google.example.library.v1.DeleteBookRequest; +import com.google.example.library.v1.DeleteShelfRequest; +import com.google.example.library.v1.FindRelatedBooksRequest; +import com.google.example.library.v1.FindRelatedBooksResponse; +import com.google.example.library.v1.FolderName; +import com.google.example.library.v1.GetBigBookMetadata; +import com.google.example.library.v1.GetBookFromAbsolutelyAnywhereRequest; +import com.google.example.library.v1.GetBookFromAnywhereRequest; +import com.google.example.library.v1.GetBookFromArchiveRequest; +import com.google.example.library.v1.GetBookRequest; +import com.google.example.library.v1.GetShelfRequest; +import com.google.example.library.v1.Inventory; +import com.google.example.library.v1.InventoryName; +import static com.google.example.library.v1.LibraryServiceClient.FindRelatedBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListStringsPagedResponse; +import com.google.example.library.v1.LibraryServiceSettings; +import com.google.example.library.v1.ListBooksRequest; +import com.google.example.library.v1.ListBooksResponse; +import com.google.example.library.v1.ListShelvesRequest; +import com.google.example.library.v1.ListShelvesResponse; +import com.google.example.library.v1.ListStringsRequest; +import com.google.example.library.v1.ListStringsResponse; +import com.google.example.library.v1.LocationName; +import com.google.example.library.v1.MergeShelvesRequest; +import com.google.example.library.v1.MoveBookRequest; +import com.google.example.library.v1.MoveBooksRequest; +import com.google.example.library.v1.MoveBooksResponse; +import com.google.example.library.v1.ProjectName; +import com.google.example.library.v1.PublishSeriesRequest; +import com.google.example.library.v1.PublishSeriesResponse; +import com.google.example.library.v1.PublisherName; +import com.google.example.library.v1.SeriesUuid; +import com.google.example.library.v1.Shelf; +import com.google.example.library.v1.ShelfName; +import com.google.example.library.v1.SomeMessage; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest.InnerMessage; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsResponse; +import com.google.example.library.v1.UpdateBookIndexRequest; +import com.google.example.library.v1.UpdateBookRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.BoolValue; +import com.google.protobuf.ByteString; +import com.google.protobuf.BytesValue; +import com.google.protobuf.DoubleValue; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.FloatValue; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Int64Value; +import com.google.protobuf.ListValue; +import com.google.protobuf.StringValue; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; +import com.google.protobuf.UInt32Value; +import com.google.protobuf.UInt64Value; +import com.google.protobuf.Value; +import com.google.tagger.v1.TaggerProto.AddTagRequest; +import com.google.tagger.v1.TaggerProto.AddTagResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * REST stub implementation for Google Example Library API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class HttpJsonLibraryServiceStub extends LibraryServiceStub { + + @InternalApi + public static final ApiMethodDescriptor createShelfMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.CreateShelf") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/bookShelves", + new FieldsExtractor>() { + @Override + public Map extract(CreateShelfRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(CreateShelfRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(CreateShelfRequest request) { + return ProtoRestSerializer.create().toBody("shelf", request.getShelf()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Shelf.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor getShelfMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.GetShelf") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*}", + new FieldsExtractor>() { + @Override + public Map extract(GetShelfRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(GetShelfRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "message", request.getMessage()); + serializer.putQueryParam(fields, "stringBuilder", request.getStringBuilder()); + serializer.putQueryParam(fields, "options", request.getOptions()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(GetShelfRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Shelf.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor listShelvesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.ListShelves") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/bookShelves", + new FieldsExtractor>() { + @Override + public Map extract(ListShelvesRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(ListShelvesRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(ListShelvesRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListShelvesResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor deleteShelfMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.DeleteShelf") + .setHttpMethod(HttpMethods.DELETE) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/bookShelves/{name}", + new FieldsExtractor>() { + @Override + public Map extract(DeleteShelfRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(DeleteShelfRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(DeleteShelfRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor mergeShelvesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.MergeShelves") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*}/merge", + new FieldsExtractor>() { + @Override + public Map extract(MergeShelvesRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(MergeShelvesRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(MergeShelvesRequest request) { + return ProtoRestSerializer.create().toBody("otherShelfName", request.getOtherShelfName()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Shelf.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor createBookMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.CreateBook") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*}/books", + new FieldsExtractor>() { + @Override + public Map extract(CreateBookRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(CreateBookRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(CreateBookRequest request) { + return ProtoRestSerializer.create().toBody("book", request.getBook()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Book.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor publishSeriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.PublishSeries") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/publish", + new FieldsExtractor>() { + @Override + public Map extract(PublishSeriesRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(PublishSeriesRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(PublishSeriesRequest request) { + return ProtoRestSerializer.create().toBody("shelf", request.getShelf()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PublishSeriesResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor createInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.CreateInventory") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/publishers/*}", + new FieldsExtractor>() { + @Override + public Map extract(CreateInventoryRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(CreateInventoryRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "asset", request.getAsset()); + serializer.putQueryParam(fields, "parentAsset", request.getParentAsset()); + serializer.putQueryParam(fields, "assets", request.getAssetsList()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(CreateInventoryRequest request) { + return ProtoRestSerializer.create().toBody("inventory", request.getInventory()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Inventory.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor getBookMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.GetBook") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*/books/*}", + new FieldsExtractor>() { + @Override + public Map extract(GetBookRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(GetBookRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(GetBookRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Book.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor listBooksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.ListBooks") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*}/books", + new FieldsExtractor>() { + @Override + public Map extract(ListBooksRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(ListBooksRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "filter", request.getFilter()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(ListBooksRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListBooksResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor deleteBookMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.DeleteBook") + .setHttpMethod(HttpMethods.DELETE) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*/books/*}", + new FieldsExtractor>() { + @Override + public Map extract(DeleteBookRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(DeleteBookRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(DeleteBookRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor updateBookMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.UpdateBook") + .setHttpMethod(HttpMethods.PUT) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*/books/*}", + new FieldsExtractor>() { + @Override + public Map extract(UpdateBookRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(UpdateBookRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "optionalFoo", request.getOptionalFoo()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam(fields, "physicalMask", request.getPhysicalMask()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(UpdateBookRequest request) { + return ProtoRestSerializer.create().toBody("book", request.getBook()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Book.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor moveBookMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.MoveBook") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*/books/*}/move", + new FieldsExtractor>() { + @Override + public Map extract(MoveBookRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(MoveBookRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(MoveBookRequest request) { + return ProtoRestSerializer.create().toBody("otherShelfName", request.getOtherShelfName()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Book.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor listStringsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.ListStrings") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/strings", + new FieldsExtractor>() { + @Override + public Map extract(ListStringsRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(ListStringsRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "name", request.getName()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(ListStringsRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListStringsResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor addCommentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.AddComments") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*}/comments", + new FieldsExtractor>() { + @Override + public Map extract(AddCommentsRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(AddCommentsRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(AddCommentsRequest request) { + return ProtoRestSerializer.create().toBody("comments", request.getCommentsList()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor getBookFromArchiveMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.GetBookFromArchive") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=archives/*/books/*}", + new FieldsExtractor>() { + @Override + public Map extract(GetBookFromArchiveRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(GetBookFromArchiveRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "parent", request.getParent()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(GetBookFromArchiveRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BookFromArchive.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor getBookFromAnywhereMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.GetBookFromAnywhere") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=archives/*/books/**}", + new FieldsExtractor>() { + @Override + public Map extract(GetBookFromAnywhereRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(GetBookFromAnywhereRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "altBookName", request.getAltBookName()); + serializer.putQueryParam(fields, "place", request.getPlace()); + serializer.putQueryParam(fields, "folder", request.getFolder()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(GetBookFromAnywhereRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BookFromAnywhere.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor getBookFromAbsolutelyAnywhereMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.GetBookFromAbsolutelyAnywhere") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=archives/*/books/*}", + new FieldsExtractor>() { + @Override + public Map extract(GetBookFromAbsolutelyAnywhereRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(GetBookFromAbsolutelyAnywhereRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "altBookName", request.getAltBookName()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(GetBookFromAbsolutelyAnywhereRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BookFromAnywhere.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor updateBookIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.UpdateBookIndex") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*/books/*}/index", + new FieldsExtractor>() { + @Override + public Map extract(UpdateBookIndexRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(UpdateBookIndexRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(UpdateBookIndexRequest request) { + return ProtoRestSerializer.create().toBody("indexName", request.getIndexName()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor findRelatedBooksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.FindRelatedBooks") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/bookShelves", + new FieldsExtractor>() { + @Override + public Map extract(FindRelatedBooksRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(FindRelatedBooksRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "names", request.getNamesList()); + serializer.putQueryParam(fields, "shelves", request.getShelvesList()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(FindRelatedBooksRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(FindRelatedBooksResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor addTagMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.AddTag") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource=bookShelves/*/books/*}/addTag", + new FieldsExtractor>() { + @Override + public Map extract(AddTagRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "resource", request.getResource()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(AddTagRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(AddTagRequest request) { + return ProtoRestSerializer.create().toBody("tag", request.getTag()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AddTagResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor getBigBookMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.GetBigBook") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*/books/*}/big", + new FieldsExtractor>() { + @Override + public Map extract(GetBookRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(GetBookRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(GetBookRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor getBigNothingMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.GetBigNothing") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=bookShelves/*/books/*}/bignothing", + new FieldsExtractor>() { + @Override + public Map extract(GetBookRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(GetBookRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(GetBookRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor moveBooksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.MoveBooks") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{source=**}/move", + new FieldsExtractor>() { + @Override + public Map extract(MoveBooksRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "source", request.getSource()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(MoveBooksRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(MoveBooksRequest request) { + return ProtoRestSerializer.create().toBody("destination", request.getDestination()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(MoveBooksResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor archiveBooksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.ArchiveBooks") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{source=**}/archive", + new FieldsExtractor>() { + @Override + public Map extract(ArchiveBooksRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "source", request.getSource()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(ArchiveBooksRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(ArchiveBooksRequest request) { + return ProtoRestSerializer.create().toBody("archive", request.getArchive()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ArchiveBooksResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor longRunningArchiveBooksMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.LongRunningArchiveBooks") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{source=**}/longrunningmove", + new FieldsExtractor>() { + @Override + public Map extract(ArchiveBooksRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "source", request.getSource()); + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(ArchiveBooksRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(ArchiveBooksRequest request) { + return ProtoRestSerializer.create().toBody("archive", request.getArchive()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor saveBookMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.SaveBook") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/saveBook", + new FieldsExtractor>() { + @Override + public Map extract(Book request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(Book request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(Book request) { + return ProtoRestSerializer.create().toBody("name", request.getName()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor testOptionalRequiredFlatteningParamsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.TestOptionalRequiredFlatteningParams") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/testofp", + new FieldsExtractor>() { + @Override + public Map extract(TestOptionalRequiredFlatteningParamsRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(TestOptionalRequiredFlatteningParamsRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(TestOptionalRequiredFlatteningParamsRequest request) { + return ProtoRestSerializer.create().toBody("requiredSingularInt32", request.getRequiredSingularInt32()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(TestOptionalRequiredFlatteningParamsResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor privateListShelvesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.LibraryService.PrivateListShelves") + .setHttpMethod(HttpMethods.GET) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/bookShelves", + new FieldsExtractor>() { + @Override + public Map extract(ListShelvesRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(ListShelvesRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(ListShelvesRequest request) { + return ""; + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Book.getDefaultInstance()) + .build()) + .build(); + + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + + private final UnaryCallable createShelfCallable; + private final UnaryCallable getShelfCallable; + private final UnaryCallable listShelvesCallable; + private final UnaryCallable deleteShelfCallable; + private final UnaryCallable mergeShelvesCallable; + private final UnaryCallable createBookCallable; + private final UnaryCallable publishSeriesCallable; + private final UnaryCallable createInventoryCallable; + private final UnaryCallable getBookCallable; + private final UnaryCallable listBooksCallable; + private final UnaryCallable listBooksPagedCallable; + private final UnaryCallable deleteBookCallable; + private final UnaryCallable updateBookCallable; + private final UnaryCallable moveBookCallable; + private final UnaryCallable listStringsCallable; + private final UnaryCallable listStringsPagedCallable; + private final UnaryCallable addCommentsCallable; + private final UnaryCallable getBookFromArchiveCallable; + private final UnaryCallable getBookFromAnywhereCallable; + private final UnaryCallable getBookFromAbsolutelyAnywhereCallable; + private final UnaryCallable updateBookIndexCallable; + private final UnaryCallable findRelatedBooksCallable; + private final UnaryCallable findRelatedBooksPagedCallable; + private final UnaryCallable addTagCallable; + private final UnaryCallable getBigBookCallable; + private final OperationCallable getBigBookOperationCallable; + private final UnaryCallable getBigNothingCallable; + private final OperationCallable getBigNothingOperationCallable; + private final UnaryCallable moveBooksCallable; + private final UnaryCallable archiveBooksCallable; + private final UnaryCallable longRunningArchiveBooksCallable; + private final OperationCallable longRunningArchiveBooksOperationCallable; + private final UnaryCallable saveBookCallable; + private final UnaryCallable testOptionalRequiredFlatteningParamsCallable; + private final UnaryCallable privateListShelvesCallable; + + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonLibraryServiceStub create(LibraryServiceStubSettings settings) throws IOException { + return new HttpJsonLibraryServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonLibraryServiceStub create(ClientContext clientContext) throws IOException { + return new HttpJsonLibraryServiceStub(LibraryServiceStubSettings.newBuilder().build(), clientContext); + } + + public static final HttpJsonLibraryServiceStub create(ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonLibraryServiceStub(LibraryServiceStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonLibraryServiceStub, using the given settings. + * This is protected so that it is easy to make a subclass, but otherwise, the static + * factory methods should be preferred. + */ + protected HttpJsonLibraryServiceStub(LibraryServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonLibraryServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonLibraryServiceStub, using the given settings. + * This is protected so that it is easy to make a subclass, but otherwise, the static + * factory methods should be preferred. + */ + protected HttpJsonLibraryServiceStub(LibraryServiceStubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + HttpJsonCallSettings createShelfTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createShelfMethodDescriptor) + .build(); + HttpJsonCallSettings getShelfTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getShelfMethodDescriptor) + .build(); + HttpJsonCallSettings listShelvesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listShelvesMethodDescriptor) + .build(); + HttpJsonCallSettings deleteShelfTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteShelfMethodDescriptor) + .build(); + HttpJsonCallSettings mergeShelvesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(mergeShelvesMethodDescriptor) + .build(); + HttpJsonCallSettings createBookTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBookMethodDescriptor) + .build(); + HttpJsonCallSettings publishSeriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(publishSeriesMethodDescriptor) + .build(); + HttpJsonCallSettings createInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createInventoryMethodDescriptor) + .build(); + HttpJsonCallSettings getBookTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBookMethodDescriptor) + .build(); + HttpJsonCallSettings listBooksTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listBooksMethodDescriptor) + .build(); + HttpJsonCallSettings deleteBookTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBookMethodDescriptor) + .build(); + HttpJsonCallSettings updateBookTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBookMethodDescriptor) + .build(); + HttpJsonCallSettings moveBookTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(moveBookMethodDescriptor) + .build(); + HttpJsonCallSettings listStringsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listStringsMethodDescriptor) + .build(); + HttpJsonCallSettings addCommentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addCommentsMethodDescriptor) + .build(); + HttpJsonCallSettings getBookFromArchiveTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBookFromArchiveMethodDescriptor) + .build(); + HttpJsonCallSettings getBookFromAnywhereTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBookFromAnywhereMethodDescriptor) + .build(); + HttpJsonCallSettings getBookFromAbsolutelyAnywhereTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBookFromAbsolutelyAnywhereMethodDescriptor) + .build(); + HttpJsonCallSettings updateBookIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBookIndexMethodDescriptor) + .build(); + HttpJsonCallSettings findRelatedBooksTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(findRelatedBooksMethodDescriptor) + .build(); + HttpJsonCallSettings addTagTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(addTagMethodDescriptor) + .build(); + HttpJsonCallSettings getBigBookTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBigBookMethodDescriptor) + .build(); + HttpJsonCallSettings getBigNothingTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBigNothingMethodDescriptor) + .build(); + HttpJsonCallSettings moveBooksTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(moveBooksMethodDescriptor) + .build(); + HttpJsonCallSettings archiveBooksTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(archiveBooksMethodDescriptor) + .build(); + HttpJsonCallSettings longRunningArchiveBooksTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(longRunningArchiveBooksMethodDescriptor) + .build(); + HttpJsonCallSettings saveBookTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(saveBookMethodDescriptor) + .build(); + HttpJsonCallSettings testOptionalRequiredFlatteningParamsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(testOptionalRequiredFlatteningParamsMethodDescriptor) + .build(); + HttpJsonCallSettings privateListShelvesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(privateListShelvesMethodDescriptor) + .build(); + + this.createShelfCallable = callableFactory.createUnaryCallable(createShelfTransportSettings,settings.createShelfSettings(), clientContext); + this.getShelfCallable = callableFactory.createUnaryCallable(getShelfTransportSettings,settings.getShelfSettings(), clientContext); + this.listShelvesCallable = callableFactory.createUnaryCallable(listShelvesTransportSettings,settings.listShelvesSettings(), clientContext); + this.deleteShelfCallable = callableFactory.createUnaryCallable(deleteShelfTransportSettings,settings.deleteShelfSettings(), clientContext); + this.mergeShelvesCallable = callableFactory.createUnaryCallable(mergeShelvesTransportSettings,settings.mergeShelvesSettings(), clientContext); + this.createBookCallable = callableFactory.createUnaryCallable(createBookTransportSettings,settings.createBookSettings(), clientContext); + this.publishSeriesCallable = callableFactory.createUnaryCallable(publishSeriesTransportSettings,settings.publishSeriesSettings(), clientContext); + this.createInventoryCallable = callableFactory.createUnaryCallable(createInventoryTransportSettings,settings.createInventorySettings(), clientContext); + this.getBookCallable = callableFactory.createUnaryCallable(getBookTransportSettings,settings.getBookSettings(), clientContext); + this.listBooksCallable = callableFactory.createUnaryCallable(listBooksTransportSettings,settings.listBooksSettings(), clientContext); + this.listBooksPagedCallable = callableFactory.createPagedCallable(listBooksTransportSettings,settings.listBooksSettings(), clientContext); + this.deleteBookCallable = callableFactory.createUnaryCallable(deleteBookTransportSettings,settings.deleteBookSettings(), clientContext); + this.updateBookCallable = callableFactory.createUnaryCallable(updateBookTransportSettings,settings.updateBookSettings(), clientContext); + this.moveBookCallable = callableFactory.createUnaryCallable(moveBookTransportSettings,settings.moveBookSettings(), clientContext); + this.listStringsCallable = callableFactory.createUnaryCallable(listStringsTransportSettings,settings.listStringsSettings(), clientContext); + this.listStringsPagedCallable = callableFactory.createPagedCallable(listStringsTransportSettings,settings.listStringsSettings(), clientContext); + this.addCommentsCallable = callableFactory.createUnaryCallable(addCommentsTransportSettings,settings.addCommentsSettings(), clientContext); + this.getBookFromArchiveCallable = callableFactory.createUnaryCallable(getBookFromArchiveTransportSettings,settings.getBookFromArchiveSettings(), clientContext); + this.getBookFromAnywhereCallable = callableFactory.createUnaryCallable(getBookFromAnywhereTransportSettings,settings.getBookFromAnywhereSettings(), clientContext); + this.getBookFromAbsolutelyAnywhereCallable = callableFactory.createUnaryCallable(getBookFromAbsolutelyAnywhereTransportSettings,settings.getBookFromAbsolutelyAnywhereSettings(), clientContext); + this.updateBookIndexCallable = callableFactory.createUnaryCallable(updateBookIndexTransportSettings,settings.updateBookIndexSettings(), clientContext); + this.findRelatedBooksCallable = callableFactory.createUnaryCallable(findRelatedBooksTransportSettings,settings.findRelatedBooksSettings(), clientContext); + this.findRelatedBooksPagedCallable = callableFactory.createPagedCallable(findRelatedBooksTransportSettings,settings.findRelatedBooksSettings(), clientContext); + this.addTagCallable = callableFactory.createUnaryCallable(addTagTransportSettings,settings.addTagSettings(), clientContext); + this.getBigBookCallable = callableFactory.createUnaryCallable(getBigBookTransportSettings,settings.getBigBookSettings(), clientContext); + this.getBigBookOperationCallable = callableFactory.createOperationCallable( + getBigBookTransportSettings,settings.getBigBookOperationSettings(), clientContext, this.operationsStub); + this.getBigNothingCallable = callableFactory.createUnaryCallable(getBigNothingTransportSettings,settings.getBigNothingSettings(), clientContext); + this.getBigNothingOperationCallable = callableFactory.createOperationCallable( + getBigNothingTransportSettings,settings.getBigNothingOperationSettings(), clientContext, this.operationsStub); + this.moveBooksCallable = callableFactory.createUnaryCallable(moveBooksTransportSettings,settings.moveBooksSettings(), clientContext); + this.archiveBooksCallable = callableFactory.createUnaryCallable(archiveBooksTransportSettings,settings.archiveBooksSettings(), clientContext); + this.longRunningArchiveBooksCallable = callableFactory.createUnaryCallable(longRunningArchiveBooksTransportSettings,settings.longRunningArchiveBooksSettings(), clientContext); + this.longRunningArchiveBooksOperationCallable = callableFactory.createOperationCallable( + longRunningArchiveBooksTransportSettings,settings.longRunningArchiveBooksOperationSettings(), clientContext, this.operationsStub); + this.saveBookCallable = callableFactory.createUnaryCallable(saveBookTransportSettings,settings.saveBookSettings(), clientContext); + this.testOptionalRequiredFlatteningParamsCallable = callableFactory.createUnaryCallable(testOptionalRequiredFlatteningParamsTransportSettings,settings.testOptionalRequiredFlatteningParamsSettings(), clientContext); + this.privateListShelvesCallable = callableFactory.createUnaryCallable(privateListShelvesTransportSettings,settings.privateListShelvesSettings(), clientContext); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + public UnaryCallable createShelfCallable() { + return createShelfCallable; + } + + public UnaryCallable getShelfCallable() { + return getShelfCallable; + } + + public UnaryCallable listShelvesCallable() { + return listShelvesCallable; + } + + public UnaryCallable deleteShelfCallable() { + return deleteShelfCallable; + } + + public UnaryCallable mergeShelvesCallable() { + return mergeShelvesCallable; + } + + public UnaryCallable createBookCallable() { + return createBookCallable; + } + + public UnaryCallable publishSeriesCallable() { + return publishSeriesCallable; + } + + public UnaryCallable createInventoryCallable() { + return createInventoryCallable; + } + + public UnaryCallable getBookCallable() { + return getBookCallable; + } + + public UnaryCallable listBooksPagedCallable() { + return listBooksPagedCallable; + } + + public UnaryCallable listBooksCallable() { + return listBooksCallable; + } + + public UnaryCallable deleteBookCallable() { + return deleteBookCallable; + } + + public UnaryCallable updateBookCallable() { + return updateBookCallable; + } + + public UnaryCallable moveBookCallable() { + return moveBookCallable; + } + + public UnaryCallable listStringsPagedCallable() { + return listStringsPagedCallable; + } + + public UnaryCallable listStringsCallable() { + return listStringsCallable; + } + + public UnaryCallable addCommentsCallable() { + return addCommentsCallable; + } + + public UnaryCallable getBookFromArchiveCallable() { + return getBookFromArchiveCallable; + } + + public UnaryCallable getBookFromAnywhereCallable() { + return getBookFromAnywhereCallable; + } + + public UnaryCallable getBookFromAbsolutelyAnywhereCallable() { + return getBookFromAbsolutelyAnywhereCallable; + } + + public UnaryCallable updateBookIndexCallable() { + return updateBookIndexCallable; + } + + public UnaryCallable findRelatedBooksPagedCallable() { + return findRelatedBooksPagedCallable; + } + + public UnaryCallable findRelatedBooksCallable() { + return findRelatedBooksCallable; + } + + public UnaryCallable addTagCallable() { + return addTagCallable; + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable getBigBookOperationCallable() { + return getBigBookOperationCallable; + } + + public UnaryCallable getBigBookCallable() { + return getBigBookCallable; + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable getBigNothingOperationCallable() { + return getBigNothingOperationCallable; + } + + public UnaryCallable getBigNothingCallable() { + return getBigNothingCallable; + } + + public UnaryCallable moveBooksCallable() { + return moveBooksCallable; + } + + public UnaryCallable archiveBooksCallable() { + return archiveBooksCallable; + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable longRunningArchiveBooksOperationCallable() { + return longRunningArchiveBooksOperationCallable; + } + + public UnaryCallable longRunningArchiveBooksCallable() { + return longRunningArchiveBooksCallable; + } + + public UnaryCallable saveBookCallable() { + return saveBookCallable; + } + + public UnaryCallable testOptionalRequiredFlatteningParamsCallable() { + return testOptionalRequiredFlatteningParamsCallable; + } + + public UnaryCallable privateListShelvesCallable() { + return privateListShelvesCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } + +} +============== file: src/main/java/com/google/example/library/v1/stub/HttpJsonMyProtoCallableFactory.java ============== +/* + * 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.example.library.v1.stub; + +import com.google.api.client.http.HttpMethods; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMessage; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.FieldsExtractor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.RequestParamsExtractor; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import com.google.example.library.v1.MyProtoSettings; +import com.google.protos.google.example.library.v1.AnotherService.MethodRequest; +import com.google.protos.google.example.library.v1.AnotherService.MethodResponse; +import com.google.protos.google.example.library.v1.AnotherService.Namespace; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; +import javax.annotation.Nullable; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * REST callable factory implementation for Google Example Library API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") +public class HttpJsonMyProtoCallableFactory implements HttpJsonStubCallableFactory< + ApiMessage, BackgroundResource> { + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable(httpJsonCallSettings, callSettings, clientContext); + } + + + @BetaApi("The surface for long-running operations is not stable yet and may change in the future.") + @Override + @Nullable + public OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings operationCallSettings, + ClientContext clientContext, BackgroundResource operationsStub) { + return null; + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings pagedCallSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable(httpJsonCallSettings, pagedCallSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings batchingCallSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable(httpJsonCallSettings, batchingCallSettings, clientContext); + } +} +============== file: src/main/java/com/google/example/library/v1/stub/HttpJsonMyProtoStub.java ============== +/* + * 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.example.library.v1.stub; + +import com.google.api.client.http.HttpMethods; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.FieldsExtractor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.RequestParamsExtractor; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import com.google.example.library.v1.MyProtoSettings; +import com.google.protos.google.example.library.v1.AnotherService.MethodRequest; +import com.google.protos.google.example.library.v1.AnotherService.MethodResponse; +import com.google.protos.google.example.library.v1.AnotherService.Namespace; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * REST stub implementation for Google Example Library API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public class HttpJsonMyProtoStub extends MyProtoStub { + + @InternalApi + public static final ApiMethodDescriptor myMethodMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.MyProto.MyMethod") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/myMethod", + new FieldsExtractor>() { + @Override + public Map extract(MethodRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(MethodRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(MethodRequest request) { + return ProtoRestSerializer.create().toBody("mylist", request.getMylistList()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(MethodResponse.getDefaultInstance()) + .build()) + .build(); + @InternalApi + public static final ApiMethodDescriptor getNamespaceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.example.library.v1.MyProto.GetNamespace") + .setHttpMethod(HttpMethods.POST) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/myMethod", + new FieldsExtractor>() { + @Override + public Map extract(MethodRequest request) { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setQueryParamsExtractor( + new FieldsExtractor>>() { + @Override + public Map> extract(MethodRequest request) { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + + return fields; + } + }) + .setRequestBodyExtractor( + new FieldsExtractor() { + @Override + public String extract(MethodRequest request) { + return ProtoRestSerializer.create().toBody("mylist", request.getMylistList()); + } + }) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Namespace.getDefaultInstance()) + .build()) + .build(); + + + private final BackgroundResource backgroundResources; + + private final UnaryCallable myMethodCallable; + private final UnaryCallable getNamespaceCallable; + + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonMyProtoStub create(MyProtoStubSettings settings) throws IOException { + return new HttpJsonMyProtoStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonMyProtoStub create(ClientContext clientContext) throws IOException { + return new HttpJsonMyProtoStub(MyProtoStubSettings.newBuilder().build(), clientContext); + } + + public static final HttpJsonMyProtoStub create(ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonMyProtoStub(MyProtoStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonMyProtoStub, using the given settings. + * This is protected so that it is easy to make a subclass, but otherwise, the static + * factory methods should be preferred. + */ + protected HttpJsonMyProtoStub(MyProtoStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonMyProtoCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonMyProtoStub, using the given settings. + * This is protected so that it is easy to make a subclass, but otherwise, the static + * factory methods should be preferred. + */ + protected HttpJsonMyProtoStub(MyProtoStubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings myMethodTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(myMethodMethodDescriptor) + .build(); + HttpJsonCallSettings getNamespaceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getNamespaceMethodDescriptor) + .build(); + + this.myMethodCallable = callableFactory.createUnaryCallable(myMethodTransportSettings,settings.myMethodSettings(), clientContext); + this.getNamespaceCallable = callableFactory.createUnaryCallable(getNamespaceTransportSettings,settings.getNamespaceSettings(), clientContext); + + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + + public UnaryCallable myMethodCallable() { + return myMethodCallable; + } + + public UnaryCallable getNamespaceCallable() { + return getNamespaceCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } + +} +============== file: src/main/java/com/google/example/library/v1/stub/LibraryServiceStub.java ============== +/* + * 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.example.library.v1.stub; + +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.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.resourcenames.ResourceName; +import com.google.example.library.v1.AddCommentsRequest; +import com.google.example.library.v1.ArchiveBooksMetadata; +import com.google.example.library.v1.ArchiveBooksRequest; +import com.google.example.library.v1.ArchiveBooksResponse; +import com.google.example.library.v1.ArchiveName; +import com.google.example.library.v1.ArchivedBookName; +import com.google.example.library.v1.Book; +import com.google.example.library.v1.BookFromAnywhere; +import com.google.example.library.v1.BookFromArchive; +import com.google.example.library.v1.BookName; +import com.google.example.library.v1.Comment; +import com.google.example.library.v1.CreateBookRequest; +import com.google.example.library.v1.CreateInventoryRequest; +import com.google.example.library.v1.CreateShelfRequest; +import com.google.example.library.v1.DeleteBookRequest; +import com.google.example.library.v1.DeleteShelfRequest; +import com.google.example.library.v1.FindRelatedBooksRequest; +import com.google.example.library.v1.FindRelatedBooksResponse; +import com.google.example.library.v1.FolderName; +import com.google.example.library.v1.GetBigBookMetadata; +import com.google.example.library.v1.GetBookFromAbsolutelyAnywhereRequest; +import com.google.example.library.v1.GetBookFromAnywhereRequest; +import com.google.example.library.v1.GetBookFromArchiveRequest; +import com.google.example.library.v1.GetBookRequest; +import com.google.example.library.v1.GetShelfRequest; +import com.google.example.library.v1.Inventory; +import com.google.example.library.v1.InventoryName; +import static com.google.example.library.v1.LibraryServiceClient.FindRelatedBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListStringsPagedResponse; +import com.google.example.library.v1.ListBooksRequest; +import com.google.example.library.v1.ListBooksResponse; +import com.google.example.library.v1.ListShelvesRequest; +import com.google.example.library.v1.ListShelvesResponse; +import com.google.example.library.v1.ListStringsRequest; +import com.google.example.library.v1.ListStringsResponse; +import com.google.example.library.v1.LocationName; +import com.google.example.library.v1.MergeShelvesRequest; +import com.google.example.library.v1.MoveBookRequest; +import com.google.example.library.v1.MoveBooksRequest; +import com.google.example.library.v1.MoveBooksResponse; +import com.google.example.library.v1.ProjectName; +import com.google.example.library.v1.PublishSeriesRequest; +import com.google.example.library.v1.PublishSeriesResponse; +import com.google.example.library.v1.PublisherName; +import com.google.example.library.v1.SeriesUuid; +import com.google.example.library.v1.Shelf; +import com.google.example.library.v1.ShelfName; +import com.google.example.library.v1.SomeMessage; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest.InnerMessage; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsResponse; +import com.google.example.library.v1.UpdateBookIndexRequest; +import com.google.example.library.v1.UpdateBookRequest; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import com.google.protobuf.Any; +import com.google.protobuf.BoolValue; +import com.google.protobuf.ByteString; +import com.google.protobuf.BytesValue; +import com.google.protobuf.DoubleValue; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.FloatValue; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Int64Value; +import com.google.protobuf.ListValue; +import com.google.protobuf.StringValue; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; +import com.google.protobuf.UInt32Value; +import com.google.protobuf.UInt64Value; +import com.google.protobuf.Value; +import com.google.tagger.v1.TaggerProto.AddTagRequest; +import com.google.tagger.v1.TaggerProto.AddTagResponse; +import java.util.List; +import java.util.Map; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Google Example Library API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class LibraryServiceStub implements BackgroundResource { + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationsStub getOperationsStub() { + throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + } + + public UnaryCallable createShelfCallable() { + throw new UnsupportedOperationException("Not implemented: createShelfCallable()"); + } + + public UnaryCallable getShelfCallable() { + throw new UnsupportedOperationException("Not implemented: getShelfCallable()"); + } + + public UnaryCallable listShelvesCallable() { + throw new UnsupportedOperationException("Not implemented: listShelvesCallable()"); + } + + public UnaryCallable deleteShelfCallable() { + throw new UnsupportedOperationException("Not implemented: deleteShelfCallable()"); + } + + public UnaryCallable mergeShelvesCallable() { + throw new UnsupportedOperationException("Not implemented: mergeShelvesCallable()"); + } + + public UnaryCallable createBookCallable() { + throw new UnsupportedOperationException("Not implemented: createBookCallable()"); + } + + public UnaryCallable publishSeriesCallable() { + throw new UnsupportedOperationException("Not implemented: publishSeriesCallable()"); + } + + public UnaryCallable createInventoryCallable() { + throw new UnsupportedOperationException("Not implemented: createInventoryCallable()"); + } + + public UnaryCallable getBookCallable() { + throw new UnsupportedOperationException("Not implemented: getBookCallable()"); + } + + public UnaryCallable listBooksPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listBooksPagedCallable()"); + } + + public UnaryCallable listBooksCallable() { + throw new UnsupportedOperationException("Not implemented: listBooksCallable()"); + } + + public UnaryCallable deleteBookCallable() { + throw new UnsupportedOperationException("Not implemented: deleteBookCallable()"); + } + + public UnaryCallable updateBookCallable() { + throw new UnsupportedOperationException("Not implemented: updateBookCallable()"); + } + + public UnaryCallable moveBookCallable() { + throw new UnsupportedOperationException("Not implemented: moveBookCallable()"); + } + + public UnaryCallable listStringsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listStringsPagedCallable()"); + } + + public UnaryCallable listStringsCallable() { + throw new UnsupportedOperationException("Not implemented: listStringsCallable()"); + } + + public UnaryCallable addCommentsCallable() { + throw new UnsupportedOperationException("Not implemented: addCommentsCallable()"); + } + + public UnaryCallable getBookFromArchiveCallable() { + throw new UnsupportedOperationException("Not implemented: getBookFromArchiveCallable()"); + } + + public UnaryCallable getBookFromAnywhereCallable() { + throw new UnsupportedOperationException("Not implemented: getBookFromAnywhereCallable()"); + } + + public UnaryCallable getBookFromAbsolutelyAnywhereCallable() { + throw new UnsupportedOperationException("Not implemented: getBookFromAbsolutelyAnywhereCallable()"); + } + + public UnaryCallable updateBookIndexCallable() { + throw new UnsupportedOperationException("Not implemented: updateBookIndexCallable()"); + } + + public UnaryCallable findRelatedBooksPagedCallable() { + throw new UnsupportedOperationException("Not implemented: findRelatedBooksPagedCallable()"); + } + + public UnaryCallable findRelatedBooksCallable() { + throw new UnsupportedOperationException("Not implemented: findRelatedBooksCallable()"); + } + + public UnaryCallable addTagCallable() { + throw new UnsupportedOperationException("Not implemented: addTagCallable()"); + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable getBigBookOperationCallable() { + throw new UnsupportedOperationException("Not implemented: getBigBookOperationCallable()"); + } + + public UnaryCallable getBigBookCallable() { + throw new UnsupportedOperationException("Not implemented: getBigBookCallable()"); + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable getBigNothingOperationCallable() { + throw new UnsupportedOperationException("Not implemented: getBigNothingOperationCallable()"); + } + + public UnaryCallable getBigNothingCallable() { + throw new UnsupportedOperationException("Not implemented: getBigNothingCallable()"); + } + + public UnaryCallable moveBooksCallable() { + throw new UnsupportedOperationException("Not implemented: moveBooksCallable()"); + } + + public UnaryCallable archiveBooksCallable() { + throw new UnsupportedOperationException("Not implemented: archiveBooksCallable()"); + } + + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallable longRunningArchiveBooksOperationCallable() { + throw new UnsupportedOperationException("Not implemented: longRunningArchiveBooksOperationCallable()"); + } + + public UnaryCallable longRunningArchiveBooksCallable() { + throw new UnsupportedOperationException("Not implemented: longRunningArchiveBooksCallable()"); + } + + public UnaryCallable saveBookCallable() { + throw new UnsupportedOperationException("Not implemented: saveBookCallable()"); + } + + public UnaryCallable testOptionalRequiredFlatteningParamsCallable() { + throw new UnsupportedOperationException("Not implemented: testOptionalRequiredFlatteningParamsCallable()"); + } + + public UnaryCallable privateListShelvesCallable() { + throw new UnsupportedOperationException("Not implemented: privateListShelvesCallable()"); + } + + @Override + public abstract void close(); +} +============== file: src/main/java/com/google/example/library/v1/stub/LibraryServiceStubSettings.java ============== +/* + * 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.example.library.v1.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.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.longrunning.OperationFuture; +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.ClientSettings; +import com.google.api.gax.rpc.HeaderProvider; +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.ServerStreamingCallSettings; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StreamingCallSettings; +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.auth.Credentials; +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.common.collect.Sets; +import com.google.example.library.v1.AddCommentsRequest; +import com.google.example.library.v1.ArchiveBooksMetadata; +import com.google.example.library.v1.ArchiveBooksRequest; +import com.google.example.library.v1.ArchiveBooksResponse; +import com.google.example.library.v1.Book; +import com.google.example.library.v1.BookFromAnywhere; +import com.google.example.library.v1.BookFromArchive; +import com.google.example.library.v1.CreateBookRequest; +import com.google.example.library.v1.CreateInventoryRequest; +import com.google.example.library.v1.CreateShelfRequest; +import com.google.example.library.v1.DeleteBookRequest; +import com.google.example.library.v1.DeleteShelfRequest; +import com.google.example.library.v1.FindRelatedBooksRequest; +import com.google.example.library.v1.FindRelatedBooksResponse; +import com.google.example.library.v1.GetBigBookMetadata; +import com.google.example.library.v1.GetBookFromAbsolutelyAnywhereRequest; +import com.google.example.library.v1.GetBookFromAnywhereRequest; +import com.google.example.library.v1.GetBookFromArchiveRequest; +import com.google.example.library.v1.GetBookRequest; +import com.google.example.library.v1.GetShelfRequest; +import com.google.example.library.v1.Inventory; +import static com.google.example.library.v1.LibraryServiceClient.FindRelatedBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListStringsPagedResponse; +import com.google.example.library.v1.LibraryServiceGrpc; +import com.google.example.library.v1.ListBooksRequest; +import com.google.example.library.v1.ListBooksResponse; +import com.google.example.library.v1.ListShelvesRequest; +import com.google.example.library.v1.ListShelvesResponse; +import com.google.example.library.v1.ListStringsRequest; +import com.google.example.library.v1.ListStringsResponse; +import com.google.example.library.v1.MergeShelvesRequest; +import com.google.example.library.v1.MoveBookRequest; +import com.google.example.library.v1.MoveBooksRequest; +import com.google.example.library.v1.MoveBooksResponse; +import com.google.example.library.v1.PublishSeriesRequest; +import com.google.example.library.v1.PublishSeriesResponse; +import com.google.example.library.v1.Shelf; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsResponse; +import com.google.example.library.v1.UpdateBookIndexRequest; +import com.google.example.library.v1.UpdateBookRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.tagger.v1.TaggerProto.AddTagRequest; +import com.google.tagger.v1.TaggerProto.AddTagResponse; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link LibraryServiceStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (library-example.googleapis.com) and default port (1234) + * are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. + * When build() is called, the tree of builders is called to create the complete settings + * object. + * + * For example, to set the total timeout of createShelf to 30 seconds: + * + *

+ * 
+ * LibraryServiceStubSettings.Builder libraryServiceSettingsBuilder =
+ *     LibraryServiceStubSettings.newBuilder();
+ * libraryServiceSettingsBuilder
+ *     .createShelfSettings()
+ *     .setRetrySettings(
+ *         libraryServiceSettingsBuilder.createShelfSettings().getRetrySettings().toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * LibraryServiceStubSettings libraryServiceSettings = libraryServiceSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class LibraryServiceStubSettings extends StubSettings { + /** + * The default scopes of the service. + */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() + .add("https://www.googleapis.com/auth/cloud-platform") + .add("https://www.googleapis.com/auth/library") + .build(); + + private final UnaryCallSettings createShelfSettings; + private final UnaryCallSettings getShelfSettings; + private final UnaryCallSettings listShelvesSettings; + private final UnaryCallSettings deleteShelfSettings; + private final UnaryCallSettings mergeShelvesSettings; + private final UnaryCallSettings createBookSettings; + private final UnaryCallSettings publishSeriesSettings; + private final UnaryCallSettings createInventorySettings; + private final UnaryCallSettings getBookSettings; + private final PagedCallSettings listBooksSettings; + private final UnaryCallSettings deleteBookSettings; + private final UnaryCallSettings updateBookSettings; + private final UnaryCallSettings moveBookSettings; + private final PagedCallSettings listStringsSettings; + private final UnaryCallSettings addCommentsSettings; + private final UnaryCallSettings getBookFromArchiveSettings; + private final UnaryCallSettings getBookFromAnywhereSettings; + private final UnaryCallSettings getBookFromAbsolutelyAnywhereSettings; + private final UnaryCallSettings updateBookIndexSettings; + private final PagedCallSettings findRelatedBooksSettings; + private final UnaryCallSettings addTagSettings; + private final UnaryCallSettings getBigBookSettings; + private final OperationCallSettings getBigBookOperationSettings; + private final UnaryCallSettings getBigNothingSettings; + private final OperationCallSettings getBigNothingOperationSettings; + private final UnaryCallSettings moveBooksSettings; + private final UnaryCallSettings archiveBooksSettings; + private final UnaryCallSettings longRunningArchiveBooksSettings; + private final OperationCallSettings longRunningArchiveBooksOperationSettings; + private final UnaryCallSettings saveBookSettings; + private final UnaryCallSettings testOptionalRequiredFlatteningParamsSettings; + private final UnaryCallSettings privateListShelvesSettings; + + /** + * Returns the object with the settings used for calls to createShelf. + */ + public UnaryCallSettings createShelfSettings() { + return createShelfSettings; + } + + /** + * Returns the object with the settings used for calls to getShelf. + */ + public UnaryCallSettings getShelfSettings() { + return getShelfSettings; + } + + /** + * Returns the object with the settings used for calls to listShelves. + */ + public UnaryCallSettings listShelvesSettings() { + return listShelvesSettings; + } + + /** + * Returns the object with the settings used for calls to deleteShelf. + */ + public UnaryCallSettings deleteShelfSettings() { + return deleteShelfSettings; + } + + /** + * Returns the object with the settings used for calls to mergeShelves. + */ + public UnaryCallSettings mergeShelvesSettings() { + return mergeShelvesSettings; + } + + /** + * Returns the object with the settings used for calls to createBook. + */ + public UnaryCallSettings createBookSettings() { + return createBookSettings; + } + + /** + * Returns the object with the settings used for calls to publishSeries. + */ + public UnaryCallSettings publishSeriesSettings() { + return publishSeriesSettings; + } + + /** + * Returns the object with the settings used for calls to createInventory. + */ + public UnaryCallSettings createInventorySettings() { + return createInventorySettings; + } + + /** + * Returns the object with the settings used for calls to getBook. + */ + public UnaryCallSettings getBookSettings() { + return getBookSettings; + } + + /** + * Returns the object with the settings used for calls to listBooks. + */ + public PagedCallSettings listBooksSettings() { + return listBooksSettings; + } + + /** + * Returns the object with the settings used for calls to deleteBook. + */ + public UnaryCallSettings deleteBookSettings() { + return deleteBookSettings; + } + + /** + * Returns the object with the settings used for calls to updateBook. + */ + public UnaryCallSettings updateBookSettings() { + return updateBookSettings; + } + + /** + * Returns the object with the settings used for calls to moveBook. + */ + public UnaryCallSettings moveBookSettings() { + return moveBookSettings; + } + + /** + * Returns the object with the settings used for calls to listStrings. + */ + public PagedCallSettings listStringsSettings() { + return listStringsSettings; + } + + /** + * Returns the object with the settings used for calls to addComments. + */ + public UnaryCallSettings addCommentsSettings() { + return addCommentsSettings; + } + + /** + * Returns the object with the settings used for calls to getBookFromArchive. + */ + public UnaryCallSettings getBookFromArchiveSettings() { + return getBookFromArchiveSettings; + } + + /** + * Returns the object with the settings used for calls to getBookFromAnywhere. + */ + public UnaryCallSettings getBookFromAnywhereSettings() { + return getBookFromAnywhereSettings; + } + + /** + * Returns the object with the settings used for calls to getBookFromAbsolutelyAnywhere. + */ + public UnaryCallSettings getBookFromAbsolutelyAnywhereSettings() { + return getBookFromAbsolutelyAnywhereSettings; + } + + /** + * Returns the object with the settings used for calls to updateBookIndex. + */ + public UnaryCallSettings updateBookIndexSettings() { + return updateBookIndexSettings; + } + + /** + * Returns the object with the settings used for calls to findRelatedBooks. + */ + public PagedCallSettings findRelatedBooksSettings() { + return findRelatedBooksSettings; + } + + /** + * Returns the object with the settings used for calls to addTag. + */ + public UnaryCallSettings addTagSettings() { + return addTagSettings; + } + + /** + * Returns the object with the settings used for calls to getBigBook. + */ + public UnaryCallSettings getBigBookSettings() { + return getBigBookSettings; + } + + /** + * Returns the object with the settings used for calls to getBigBook. + */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings getBigBookOperationSettings() { + return getBigBookOperationSettings; + } + + /** + * Returns the object with the settings used for calls to getBigNothing. + */ + public UnaryCallSettings getBigNothingSettings() { + return getBigNothingSettings; + } + + /** + * Returns the object with the settings used for calls to getBigNothing. + */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings getBigNothingOperationSettings() { + return getBigNothingOperationSettings; + } + + /** + * Returns the object with the settings used for calls to moveBooks. + */ + public UnaryCallSettings moveBooksSettings() { + return moveBooksSettings; + } + + /** + * Returns the object with the settings used for calls to archiveBooks. + */ + public UnaryCallSettings archiveBooksSettings() { + return archiveBooksSettings; + } + + /** + * Returns the object with the settings used for calls to longRunningArchiveBooks. + */ + public UnaryCallSettings longRunningArchiveBooksSettings() { + return longRunningArchiveBooksSettings; + } + + /** + * Returns the object with the settings used for calls to longRunningArchiveBooks. + */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings longRunningArchiveBooksOperationSettings() { + return longRunningArchiveBooksOperationSettings; + } + + /** + * Returns the object with the settings used for calls to saveBook. + */ + public UnaryCallSettings saveBookSettings() { + return saveBookSettings; + } + + /** + * Returns the object with the settings used for calls to testOptionalRequiredFlatteningParams. + */ + public UnaryCallSettings testOptionalRequiredFlatteningParamsSettings() { + return testOptionalRequiredFlatteningParamsSettings; + } + + /** + * Returns the object with the settings used for calls to privateListShelves. + */ + public UnaryCallSettings privateListShelvesSettings() { + return privateListShelvesSettings; + } + + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public LibraryServiceStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonLibraryServiceStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** + * Returns a builder for the default ExecutorProvider for this service. + */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** + * Returns the default service endpoint. + */ + public static String getDefaultEndpoint() { + return "library-example.googleapis.com"; + } + + /** + * Returns the default service port. + */ + public static int getDefaultServicePort() { + return 1234; + } + + + /** + * Returns the default service scopes. + */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + + /** + * Returns a builder for the default credentials for this service. + */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder() + .setScopesToApply(DEFAULT_SERVICE_SCOPES) + ; + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultHttpJsonTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(LibraryServiceStubSettings.class)) + .setTransportToken(GaxHttpJsonProperties.getHttpJsonTokenName(), GaxHttpJsonProperties.getHttpJsonVersion()); + } + + /** + * Returns a new builder for this class. + */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** + * Returns a new builder for this class. + */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** + * Returns a builder containing all the values of this settings class. + */ + public Builder toBuilder() { + return new Builder(this); + } + + protected LibraryServiceStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + createShelfSettings = settingsBuilder.createShelfSettings().build(); + getShelfSettings = settingsBuilder.getShelfSettings().build(); + listShelvesSettings = settingsBuilder.listShelvesSettings().build(); + deleteShelfSettings = settingsBuilder.deleteShelfSettings().build(); + mergeShelvesSettings = settingsBuilder.mergeShelvesSettings().build(); + createBookSettings = settingsBuilder.createBookSettings().build(); + publishSeriesSettings = settingsBuilder.publishSeriesSettings().build(); + createInventorySettings = settingsBuilder.createInventorySettings().build(); + getBookSettings = settingsBuilder.getBookSettings().build(); + listBooksSettings = settingsBuilder.listBooksSettings().build(); + deleteBookSettings = settingsBuilder.deleteBookSettings().build(); + updateBookSettings = settingsBuilder.updateBookSettings().build(); + moveBookSettings = settingsBuilder.moveBookSettings().build(); + listStringsSettings = settingsBuilder.listStringsSettings().build(); + addCommentsSettings = settingsBuilder.addCommentsSettings().build(); + getBookFromArchiveSettings = settingsBuilder.getBookFromArchiveSettings().build(); + getBookFromAnywhereSettings = settingsBuilder.getBookFromAnywhereSettings().build(); + getBookFromAbsolutelyAnywhereSettings = settingsBuilder.getBookFromAbsolutelyAnywhereSettings().build(); + updateBookIndexSettings = settingsBuilder.updateBookIndexSettings().build(); + findRelatedBooksSettings = settingsBuilder.findRelatedBooksSettings().build(); + addTagSettings = settingsBuilder.addTagSettings().build(); + getBigBookSettings = settingsBuilder.getBigBookSettings().build(); + getBigBookOperationSettings = settingsBuilder.getBigBookOperationSettings().build(); + getBigNothingSettings = settingsBuilder.getBigNothingSettings().build(); + getBigNothingOperationSettings = settingsBuilder.getBigNothingOperationSettings().build(); + moveBooksSettings = settingsBuilder.moveBooksSettings().build(); + archiveBooksSettings = settingsBuilder.archiveBooksSettings().build(); + longRunningArchiveBooksSettings = settingsBuilder.longRunningArchiveBooksSettings().build(); + longRunningArchiveBooksOperationSettings = settingsBuilder.longRunningArchiveBooksOperationSettings().build(); + saveBookSettings = settingsBuilder.saveBookSettings().build(); + testOptionalRequiredFlatteningParamsSettings = settingsBuilder.testOptionalRequiredFlatteningParamsSettings().build(); + privateListShelvesSettings = settingsBuilder.privateListShelvesSettings().build(); + } + + private static final PagedListDescriptor LIST_BOOKS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + @Override + public ListBooksRequest injectToken(ListBooksRequest payload, String token) { + return ListBooksRequest + .newBuilder(payload) + .setPageToken(token) + .build(); + } + @Override + public ListBooksRequest injectPageSize(ListBooksRequest payload, int pageSize) { + return ListBooksRequest + .newBuilder(payload) + .setPageSize(pageSize) + .build(); + } + @Override + public Integer extractPageSize(ListBooksRequest payload) { + return payload.getPageSize(); + } + @Override + public String extractNextToken(ListBooksResponse payload) { + return payload.getNextPageToken(); + } + @Override + public Iterable extractResources(ListBooksResponse payload) { + return payload.getBooksList() != null ? payload.getBooksList() : + ImmutableList.of(); + } + }; + + private static final PagedListDescriptor LIST_STRINGS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + @Override + public ListStringsRequest injectToken(ListStringsRequest payload, String token) { + return ListStringsRequest + .newBuilder(payload) + .setPageToken(token) + .build(); + } + @Override + public ListStringsRequest injectPageSize(ListStringsRequest payload, int pageSize) { + return ListStringsRequest + .newBuilder(payload) + .setPageSize(pageSize) + .build(); + } + @Override + public Integer extractPageSize(ListStringsRequest payload) { + return payload.getPageSize(); + } + @Override + public String extractNextToken(ListStringsResponse payload) { + return payload.getNextPageToken(); + } + @Override + public Iterable extractResources(ListStringsResponse payload) { + return payload.getStringsList() != null ? payload.getStringsList() : + ImmutableList.of(); + } + }; + + private static final PagedListDescriptor FIND_RELATED_BOOKS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + @Override + public FindRelatedBooksRequest injectToken(FindRelatedBooksRequest payload, String token) { + return FindRelatedBooksRequest + .newBuilder(payload) + .setPageToken(token) + .build(); + } + @Override + public FindRelatedBooksRequest injectPageSize(FindRelatedBooksRequest payload, int pageSize) { + return FindRelatedBooksRequest + .newBuilder(payload) + .setPageSize(pageSize) + .build(); + } + @Override + public Integer extractPageSize(FindRelatedBooksRequest payload) { + return payload.getPageSize(); + } + @Override + public String extractNextToken(FindRelatedBooksResponse payload) { + return payload.getNextPageToken(); + } + @Override + public Iterable extractResources(FindRelatedBooksResponse payload) { + return payload.getNamesList() != null ? payload.getNamesList() : + ImmutableList.of(); + } + }; + + private static final PagedListResponseFactory LIST_BOOKS_PAGE_STR_FACT = + new PagedListResponseFactory() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListBooksRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_BOOKS_PAGE_STR_DESC, request, context); + return ListBooksPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory LIST_STRINGS_PAGE_STR_FACT = + new PagedListResponseFactory() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListStringsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_STRINGS_PAGE_STR_DESC, request, context); + return ListStringsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory FIND_RELATED_BOOKS_PAGE_STR_FACT = + new PagedListResponseFactory() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + FindRelatedBooksRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, FIND_RELATED_BOOKS_PAGE_STR_DESC, request, context); + return FindRelatedBooksPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + + /** + * Builder for LibraryServiceStubSettings. + */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final UnaryCallSettings.Builder createShelfSettings; + private final UnaryCallSettings.Builder getShelfSettings; + private final UnaryCallSettings.Builder listShelvesSettings; + private final UnaryCallSettings.Builder deleteShelfSettings; + private final UnaryCallSettings.Builder mergeShelvesSettings; + private final UnaryCallSettings.Builder createBookSettings; + private final UnaryCallSettings.Builder publishSeriesSettings; + private final UnaryCallSettings.Builder createInventorySettings; + private final UnaryCallSettings.Builder getBookSettings; + private final PagedCallSettings.Builder listBooksSettings; + private final UnaryCallSettings.Builder deleteBookSettings; + private final UnaryCallSettings.Builder updateBookSettings; + private final UnaryCallSettings.Builder moveBookSettings; + private final PagedCallSettings.Builder listStringsSettings; + private final UnaryCallSettings.Builder addCommentsSettings; + private final UnaryCallSettings.Builder getBookFromArchiveSettings; + private final UnaryCallSettings.Builder getBookFromAnywhereSettings; + private final UnaryCallSettings.Builder getBookFromAbsolutelyAnywhereSettings; + private final UnaryCallSettings.Builder updateBookIndexSettings; + private final PagedCallSettings.Builder findRelatedBooksSettings; + private final UnaryCallSettings.Builder addTagSettings; + private final UnaryCallSettings.Builder getBigBookSettings; + private final OperationCallSettings.Builder getBigBookOperationSettings; + private final UnaryCallSettings.Builder getBigNothingSettings; + private final OperationCallSettings.Builder getBigNothingOperationSettings; + private final UnaryCallSettings.Builder moveBooksSettings; + private final UnaryCallSettings.Builder archiveBooksSettings; + private final UnaryCallSettings.Builder longRunningArchiveBooksSettings; + private final OperationCallSettings.Builder longRunningArchiveBooksOperationSettings; + private final UnaryCallSettings.Builder saveBookSettings; + private final UnaryCallSettings.Builder testOptionalRequiredFlatteningParamsSettings; + private final UnaryCallSettings.Builder privateListShelvesSettings; + + private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put( + "non_idempotent", + ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + createShelfSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getShelfSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + listShelvesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + deleteShelfSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + mergeShelvesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + createBookSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + publishSeriesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + createInventorySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getBookSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + listBooksSettings = PagedCallSettings.newBuilder( + LIST_BOOKS_PAGE_STR_FACT); + + deleteBookSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + updateBookSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + moveBookSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + listStringsSettings = PagedCallSettings.newBuilder( + LIST_STRINGS_PAGE_STR_FACT); + + addCommentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getBookFromArchiveSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getBookFromAnywhereSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getBookFromAbsolutelyAnywhereSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + updateBookIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + findRelatedBooksSettings = PagedCallSettings.newBuilder( + FIND_RELATED_BOOKS_PAGE_STR_FACT); + + addTagSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getBigBookSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getBigBookOperationSettings = OperationCallSettings.newBuilder(); + + getBigNothingSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getBigNothingOperationSettings = OperationCallSettings.newBuilder(); + + moveBooksSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + archiveBooksSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + longRunningArchiveBooksSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + longRunningArchiveBooksOperationSettings = OperationCallSettings.newBuilder(); + + saveBookSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + testOptionalRequiredFlatteningParamsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + privateListShelvesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = ImmutableList.>of( + createShelfSettings, + getShelfSettings, + listShelvesSettings, + deleteShelfSettings, + mergeShelvesSettings, + createBookSettings, + publishSeriesSettings, + createInventorySettings, + getBookSettings, + listBooksSettings, + deleteBookSettings, + updateBookSettings, + moveBookSettings, + listStringsSettings, + addCommentsSettings, + getBookFromArchiveSettings, + getBookFromAnywhereSettings, + getBookFromAbsolutelyAnywhereSettings, + updateBookIndexSettings, + findRelatedBooksSettings, + addTagSettings, + getBigBookSettings, + getBigNothingSettings, + moveBooksSettings, + archiveBooksSettings, + longRunningArchiveBooksSettings, + saveBookSettings, + testOptionalRequiredFlatteningParamsSettings, + privateListShelvesSettings + ); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder.createShelfSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.getShelfSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.listShelvesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.deleteShelfSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.mergeShelvesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.createBookSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.publishSeriesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.createInventorySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.getBookSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.listBooksSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.deleteBookSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.updateBookSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.moveBookSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.listStringsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.addCommentsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.getBookFromArchiveSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.getBookFromAnywhereSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.getBookFromAbsolutelyAnywhereSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.updateBookIndexSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.findRelatedBooksSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.addTagSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.getBigBookSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.getBigNothingSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.moveBooksSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.archiveBooksSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.longRunningArchiveBooksSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.saveBookSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.testOptionalRequiredFlatteningParamsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.privateListShelvesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + builder + .getBigBookOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer(ProtoOperationTransformers.ResponseTransformer.create(Book.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(GetBigBookMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .getBigNothingOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer(ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(GetBigBookMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + builder + .longRunningArchiveBooksOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")) + .build()) + .setResponseTransformer(ProtoOperationTransformers.ResponseTransformer.create(ArchiveBooksResponse.class)) + .setMetadataTransformer(ProtoOperationTransformers.MetadataTransformer.create(ArchiveBooksMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(500L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelay(Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ZERO) // ignored + .setRpcTimeoutMultiplier(1.0) // ignored + .setMaxRpcTimeout(Duration.ZERO) // ignored + .setTotalTimeout(Duration.ofMillis(300000L)) + .build())); + + return builder; + } + + protected Builder(LibraryServiceStubSettings settings) { + super(settings); + + createShelfSettings = settings.createShelfSettings.toBuilder(); + getShelfSettings = settings.getShelfSettings.toBuilder(); + listShelvesSettings = settings.listShelvesSettings.toBuilder(); + deleteShelfSettings = settings.deleteShelfSettings.toBuilder(); + mergeShelvesSettings = settings.mergeShelvesSettings.toBuilder(); + createBookSettings = settings.createBookSettings.toBuilder(); + publishSeriesSettings = settings.publishSeriesSettings.toBuilder(); + createInventorySettings = settings.createInventorySettings.toBuilder(); + getBookSettings = settings.getBookSettings.toBuilder(); + listBooksSettings = settings.listBooksSettings.toBuilder(); + deleteBookSettings = settings.deleteBookSettings.toBuilder(); + updateBookSettings = settings.updateBookSettings.toBuilder(); + moveBookSettings = settings.moveBookSettings.toBuilder(); + listStringsSettings = settings.listStringsSettings.toBuilder(); + addCommentsSettings = settings.addCommentsSettings.toBuilder(); + getBookFromArchiveSettings = settings.getBookFromArchiveSettings.toBuilder(); + getBookFromAnywhereSettings = settings.getBookFromAnywhereSettings.toBuilder(); + getBookFromAbsolutelyAnywhereSettings = settings.getBookFromAbsolutelyAnywhereSettings.toBuilder(); + updateBookIndexSettings = settings.updateBookIndexSettings.toBuilder(); + findRelatedBooksSettings = settings.findRelatedBooksSettings.toBuilder(); + addTagSettings = settings.addTagSettings.toBuilder(); + getBigBookSettings = settings.getBigBookSettings.toBuilder(); + getBigBookOperationSettings = settings.getBigBookOperationSettings.toBuilder(); + getBigNothingSettings = settings.getBigNothingSettings.toBuilder(); + getBigNothingOperationSettings = settings.getBigNothingOperationSettings.toBuilder(); + moveBooksSettings = settings.moveBooksSettings.toBuilder(); + archiveBooksSettings = settings.archiveBooksSettings.toBuilder(); + longRunningArchiveBooksSettings = settings.longRunningArchiveBooksSettings.toBuilder(); + longRunningArchiveBooksOperationSettings = settings.longRunningArchiveBooksOperationSettings.toBuilder(); + saveBookSettings = settings.saveBookSettings.toBuilder(); + testOptionalRequiredFlatteningParamsSettings = settings.testOptionalRequiredFlatteningParamsSettings.toBuilder(); + privateListShelvesSettings = settings.privateListShelvesSettings.toBuilder(); + + unaryMethodSettingsBuilders = ImmutableList.>of( + createShelfSettings, + getShelfSettings, + listShelvesSettings, + deleteShelfSettings, + mergeShelvesSettings, + createBookSettings, + publishSeriesSettings, + createInventorySettings, + getBookSettings, + listBooksSettings, + deleteBookSettings, + updateBookSettings, + moveBookSettings, + listStringsSettings, + addCommentsSettings, + getBookFromArchiveSettings, + getBookFromAnywhereSettings, + getBookFromAbsolutelyAnywhereSettings, + updateBookIndexSettings, + findRelatedBooksSettings, + addTagSettings, + getBigBookSettings, + getBigNothingSettings, + moveBooksSettings, + archiveBooksSettings, + longRunningArchiveBooksSettings, + saveBookSettings, + testOptionalRequiredFlatteningParamsSettings, + privateListShelvesSettings + ); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + * Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods(ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** + * Returns the builder for the settings used for calls to createShelf. + */ + public UnaryCallSettings.Builder createShelfSettings() { + return createShelfSettings; + } + + /** + * Returns the builder for the settings used for calls to getShelf. + */ + public UnaryCallSettings.Builder getShelfSettings() { + return getShelfSettings; + } + + /** + * Returns the builder for the settings used for calls to listShelves. + */ + public UnaryCallSettings.Builder listShelvesSettings() { + return listShelvesSettings; + } + + /** + * Returns the builder for the settings used for calls to deleteShelf. + */ + public UnaryCallSettings.Builder deleteShelfSettings() { + return deleteShelfSettings; + } + + /** + * Returns the builder for the settings used for calls to mergeShelves. + */ + public UnaryCallSettings.Builder mergeShelvesSettings() { + return mergeShelvesSettings; + } + + /** + * Returns the builder for the settings used for calls to createBook. + */ + public UnaryCallSettings.Builder createBookSettings() { + return createBookSettings; + } + + /** + * Returns the builder for the settings used for calls to publishSeries. + */ + public UnaryCallSettings.Builder publishSeriesSettings() { + return publishSeriesSettings; + } + + /** + * Returns the builder for the settings used for calls to createInventory. + */ + public UnaryCallSettings.Builder createInventorySettings() { + return createInventorySettings; + } + + /** + * Returns the builder for the settings used for calls to getBook. + */ + public UnaryCallSettings.Builder getBookSettings() { + return getBookSettings; + } + + /** + * Returns the builder for the settings used for calls to listBooks. + */ + public PagedCallSettings.Builder listBooksSettings() { + return listBooksSettings; + } + + /** + * Returns the builder for the settings used for calls to deleteBook. + */ + public UnaryCallSettings.Builder deleteBookSettings() { + return deleteBookSettings; + } + + /** + * Returns the builder for the settings used for calls to updateBook. + */ + public UnaryCallSettings.Builder updateBookSettings() { + return updateBookSettings; + } + + /** + * Returns the builder for the settings used for calls to moveBook. + */ + public UnaryCallSettings.Builder moveBookSettings() { + return moveBookSettings; + } + + /** + * Returns the builder for the settings used for calls to listStrings. + */ + public PagedCallSettings.Builder listStringsSettings() { + return listStringsSettings; + } + + /** + * Returns the builder for the settings used for calls to addComments. + */ + public UnaryCallSettings.Builder addCommentsSettings() { + return addCommentsSettings; + } + + /** + * Returns the builder for the settings used for calls to getBookFromArchive. + */ + public UnaryCallSettings.Builder getBookFromArchiveSettings() { + return getBookFromArchiveSettings; + } + + /** + * Returns the builder for the settings used for calls to getBookFromAnywhere. + */ + public UnaryCallSettings.Builder getBookFromAnywhereSettings() { + return getBookFromAnywhereSettings; + } + + /** + * Returns the builder for the settings used for calls to getBookFromAbsolutelyAnywhere. + */ + public UnaryCallSettings.Builder getBookFromAbsolutelyAnywhereSettings() { + return getBookFromAbsolutelyAnywhereSettings; + } + + /** + * Returns the builder for the settings used for calls to updateBookIndex. + */ + public UnaryCallSettings.Builder updateBookIndexSettings() { + return updateBookIndexSettings; + } + + /** + * Returns the builder for the settings used for calls to findRelatedBooks. + */ + public PagedCallSettings.Builder findRelatedBooksSettings() { + return findRelatedBooksSettings; + } + + /** + * Returns the builder for the settings used for calls to addTag. + */ + public UnaryCallSettings.Builder addTagSettings() { + return addTagSettings; + } + + /** + * Returns the builder for the settings used for calls to getBigBook. + */ + public UnaryCallSettings.Builder getBigBookSettings() { + return getBigBookSettings; + } + + /** + * Returns the builder for the settings used for calls to getBigBook. + */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder getBigBookOperationSettings() { + return getBigBookOperationSettings; + } + + /** + * Returns the builder for the settings used for calls to getBigNothing. + */ + public UnaryCallSettings.Builder getBigNothingSettings() { + return getBigNothingSettings; + } + + /** + * Returns the builder for the settings used for calls to getBigNothing. + */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder getBigNothingOperationSettings() { + return getBigNothingOperationSettings; + } + + /** + * Returns the builder for the settings used for calls to moveBooks. + */ + public UnaryCallSettings.Builder moveBooksSettings() { + return moveBooksSettings; + } + + /** + * Returns the builder for the settings used for calls to archiveBooks. + */ + public UnaryCallSettings.Builder archiveBooksSettings() { + return archiveBooksSettings; + } + + /** + * Returns the builder for the settings used for calls to longRunningArchiveBooks. + */ + public UnaryCallSettings.Builder longRunningArchiveBooksSettings() { + return longRunningArchiveBooksSettings; + } + + /** + * Returns the builder for the settings used for calls to longRunningArchiveBooks. + */ + @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") + public OperationCallSettings.Builder longRunningArchiveBooksOperationSettings() { + return longRunningArchiveBooksOperationSettings; + } + + /** + * Returns the builder for the settings used for calls to saveBook. + */ + public UnaryCallSettings.Builder saveBookSettings() { + return saveBookSettings; + } + + /** + * Returns the builder for the settings used for calls to testOptionalRequiredFlatteningParams. + */ + public UnaryCallSettings.Builder testOptionalRequiredFlatteningParamsSettings() { + return testOptionalRequiredFlatteningParamsSettings; + } + + /** + * Returns the builder for the settings used for calls to privateListShelves. + */ + public UnaryCallSettings.Builder privateListShelvesSettings() { + return privateListShelvesSettings; + } + + @Override + public LibraryServiceStubSettings build() throws IOException { + return new LibraryServiceStubSettings(this); + } + } +} +============== file: src/main/java/com/google/example/library/v1/stub/MyProtoStub.java ============== +/* + * 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.example.library.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.protos.google.example.library.v1.AnotherService.MethodRequest; +import com.google.protos.google.example.library.v1.AnotherService.MethodResponse; +import com.google.protos.google.example.library.v1.AnotherService.Namespace; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Base stub class for Google Example Library API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +public abstract class MyProtoStub implements BackgroundResource { + + + public UnaryCallable myMethodCallable() { + throw new UnsupportedOperationException("Not implemented: myMethodCallable()"); + } + + public UnaryCallable getNamespaceCallable() { + throw new UnsupportedOperationException("Not implemented: getNamespaceCallable()"); + } + + @Override + public abstract void close(); +} +============== file: src/main/java/com/google/example/library/v1/stub/MyProtoStubSettings.java ============== +/* + * 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.example.library.v1.stub; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.HeaderProvider; +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.auth.Credentials; +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.common.collect.Sets; +import com.google.protos.google.example.library.v1.AnotherService.MethodRequest; +import com.google.protos.google.example.library.v1.AnotherService.MethodResponse; +import com.google.protos.google.example.library.v1.AnotherService.Namespace; +import com.google.protos.google.example.library.v1.MyProtoGrpc; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS +/** + * Settings class to configure an instance of {@link MyProtoStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (library-example.googleapis.com) and default port (1234) + * are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. + * When build() is called, the tree of builders is called to create the complete settings + * object. + * + * For example, to set the total timeout of myMethod to 30 seconds: + * + *

+ * 
+ * MyProtoStubSettings.Builder myProtoSettingsBuilder =
+ *     MyProtoStubSettings.newBuilder();
+ * myProtoSettingsBuilder
+ *     .myMethodSettings()
+ *     .setRetrySettings(
+ *         myProtoSettingsBuilder.myMethodSettings().getRetrySettings().toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * MyProtoStubSettings myProtoSettings = myProtoSettingsBuilder.build();
+ * 
+ * 
+ */ +@Generated("by gapic-generator") +@BetaApi +public class MyProtoStubSettings extends StubSettings { + /** + * The default scopes of the service. + */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() + .add("https://www.googleapis.com/auth/cloud-platform") + .add("https://www.googleapis.com/auth/library") + .build(); + + private final UnaryCallSettings myMethodSettings; + private final UnaryCallSettings getNamespaceSettings; + + /** + * Returns the object with the settings used for calls to myMethod. + */ + public UnaryCallSettings myMethodSettings() { + return myMethodSettings; + } + + /** + * Returns the object with the settings used for calls to getNamespace. + */ + public UnaryCallSettings getNamespaceSettings() { + return getNamespaceSettings; + } + + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public MyProtoStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonMyProtoStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); + } + } + + /** + * Returns a builder for the default ExecutorProvider for this service. + */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** + * Returns the default service endpoint. + */ + public static String getDefaultEndpoint() { + return "library-example.googleapis.com"; + } + + /** + * Returns the default service port. + */ + public static int getDefaultServicePort() { + return 1234; + } + + + /** + * Returns the default service scopes. + */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + + /** + * Returns a builder for the default credentials for this service. + */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder() + .setScopesToApply(DEFAULT_SERVICE_SCOPES) + ; + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultHttpJsonTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(MyProtoStubSettings.class)) + .setTransportToken(GaxHttpJsonProperties.getHttpJsonTokenName(), GaxHttpJsonProperties.getHttpJsonVersion()); + } + + /** + * Returns a new builder for this class. + */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** + * Returns a new builder for this class. + */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** + * Returns a builder containing all the values of this settings class. + */ + public Builder toBuilder() { + return new Builder(this); + } + + protected MyProtoStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + myMethodSettings = settingsBuilder.myMethodSettings().build(); + getNamespaceSettings = settingsBuilder.getNamespaceSettings().build(); + } + + + + + /** + * Builder for MyProtoStubSettings. + */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + + private final UnaryCallSettings.Builder myMethodSettings; + private final UnaryCallSettings.Builder getNamespaceSettings; + + private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = ImmutableMap.builder(); + definitions.put( + "idempotent", + ImmutableSet.copyOf(Lists.newArrayList(StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE))); + definitions.put( + "non_idempotent", + ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(60000L)) + .setInitialRpcTimeout(Duration.ofMillis(20000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(20000L)) + .setTotalTimeout(Duration.ofMillis(600000L)) + .build(); + definitions.put("default", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this((ClientContext) null); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + myMethodSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + getNamespaceSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = ImmutableList.>of( + myMethodSettings, + getNamespaceSettings + ); + + initDefaults(this); + } + + private static Builder createDefault() { + Builder builder = new Builder((ClientContext) null); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + + builder.myMethodSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + builder.getNamespaceSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); + + return builder; + } + + protected Builder(MyProtoStubSettings settings) { + super(settings); + + myMethodSettings = settings.myMethodSettings.toBuilder(); + getNamespaceSettings = settings.getNamespaceSettings.toBuilder(); + + unaryMethodSettingsBuilders = ImmutableList.>of( + myMethodSettings, + getNamespaceSettings + ); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + * Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods(ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** + * Returns the builder for the settings used for calls to myMethod. + */ + public UnaryCallSettings.Builder myMethodSettings() { + return myMethodSettings; + } + + /** + * Returns the builder for the settings used for calls to getNamespace. + */ + public UnaryCallSettings.Builder getNamespaceSettings() { + return getNamespaceSettings; + } + + @Override + public MyProtoStubSettings build() throws IOException { + return new MyProtoStubSettings(this); + } + } +} +============== file: src/test/java/com/google/example/library/v1/LibraryServiceClientTest.java ============== +/* + * 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.example.library.v1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode.Code; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.api.resourcenames.ResourceName; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.example.library.v1.Book; +import static com.google.example.library.v1.LibraryServiceClient.FindRelatedBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListBooksPagedResponse; +import static com.google.example.library.v1.LibraryServiceClient.ListStringsPagedResponse; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest; +import com.google.example.library.v1.TestOptionalRequiredFlatteningParamsRequest.InnerMessage; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.addCommentsMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.addTagMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.archiveBooksMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.createBookMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.createInventoryMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.createShelfMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.deleteBookMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.deleteShelfMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.findRelatedBooksMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.getBigBookMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.getBigNothingMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.getBookFromAbsolutelyAnywhereMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.getBookFromAnywhereMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.getBookFromArchiveMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.getBookMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.getShelfMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.listBooksMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.listShelvesMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.listStringsMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.longRunningArchiveBooksMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.mergeShelvesMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.moveBookMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.moveBooksMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.privateListShelvesMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.publishSeriesMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.saveBookMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.testOptionalRequiredFlatteningParamsMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.updateBookIndexMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonLibraryServiceStub.updateBookMethodDescriptor; +import com.google.example.library.v1.stub.LibraryServiceStubSettings; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.BoolValue; +import com.google.protobuf.ByteString; +import com.google.protobuf.BytesValue; +import com.google.protobuf.DoubleValue; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.FloatValue; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Int64Value; +import com.google.protobuf.ListValue; +import com.google.protobuf.StringValue; +import com.google.protobuf.Struct; +import com.google.protobuf.Timestamp; +import com.google.protobuf.UInt32Value; +import com.google.protobuf.UInt64Value; +import com.google.protobuf.Value; +import com.google.tagger.v1.TaggerProto.AddTagRequest; +import com.google.tagger.v1.TaggerProto.AddTagResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class LibraryServiceClientTest { + private static final List METHOD_DESCRIPTORS = ImmutableList.copyOf( + Lists.newArrayList( + createShelfMethodDescriptor, + getShelfMethodDescriptor, + getShelfMethodDescriptor, + getShelfMethodDescriptor, + listShelvesMethodDescriptor, + deleteShelfMethodDescriptor, + mergeShelvesMethodDescriptor, + createBookMethodDescriptor, + publishSeriesMethodDescriptor, + createInventoryMethodDescriptor, + getBookMethodDescriptor, + listBooksMethodDescriptor, + deleteBookMethodDescriptor, + updateBookMethodDescriptor, + updateBookMethodDescriptor, + moveBookMethodDescriptor, + listStringsMethodDescriptor, + listStringsMethodDescriptor, + addCommentsMethodDescriptor, + getBookFromArchiveMethodDescriptor, + getBookFromAnywhereMethodDescriptor, + getBookFromAbsolutelyAnywhereMethodDescriptor, + updateBookIndexMethodDescriptor, + findRelatedBooksMethodDescriptor, + addTagMethodDescriptor, + getBigBookMethodDescriptor, + getBigNothingMethodDescriptor, + moveBooksMethodDescriptor, + archiveBooksMethodDescriptor, + longRunningArchiveBooksMethodDescriptor, + saveBookMethodDescriptor, + testOptionalRequiredFlatteningParamsMethodDescriptor, + testOptionalRequiredFlatteningParamsMethodDescriptor, + privateListShelvesMethodDescriptor + )); + private static final MockHttpService mockService + = new MockHttpService(METHOD_DESCRIPTORS, LibraryServiceStubSettings.getDefaultEndpoint()); + + private static LibraryServiceClient client; + private static LibraryServiceSettings clientSettings; + + @BeforeClass + public static void setUp() throws IOException { + clientSettings = + LibraryServiceSettings.newBuilder() + .setTransportChannelProvider( + LibraryServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService).build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = + LibraryServiceClient.create(clientSettings); + } + + @After + public void cleanUp() { + mockService.reset(); + } + + @AfterClass + public static void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void createShelfTest() { + ShelfName name = ShelfName.of("[SHELF]"); + String theme = "theme110327241"; + String internalTheme = "internalTheme792518087"; + Shelf expectedResponse = Shelf.newBuilder() + .setName(name.toString()) + .setTheme(theme) + .setInternalTheme(internalTheme) + .build(); + mockService.addResponse(expectedResponse); + + Shelf shelf = Shelf.newBuilder().build(); + + Shelf actualResponse = + client.createShelf(shelf); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void createShelfExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Shelf shelf = Shelf.newBuilder().build(); + + client.createShelf(shelf); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getShelfTest() { + ShelfName name2 = ShelfName.of("[SHELF]"); + String theme = "theme110327241"; + String internalTheme = "internalTheme792518087"; + Shelf expectedResponse = Shelf.newBuilder() + .setName(name2.toString()) + .setTheme(theme) + .setInternalTheme(internalTheme) + .build(); + mockService.addResponse(expectedResponse); + + ShelfName name = ShelfName.of("[SHELF]"); + + Shelf actualResponse = + client.getShelf(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getShelfExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ShelfName name = ShelfName.of("[SHELF]"); + + client.getShelf(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getShelfTest2() { + ShelfName name2 = ShelfName.of("[SHELF]"); + String theme = "theme110327241"; + String internalTheme = "internalTheme792518087"; + Shelf expectedResponse = Shelf.newBuilder() + .setName(name2.toString()) + .setTheme(theme) + .setInternalTheme(internalTheme) + .build(); + mockService.addResponse(expectedResponse); + + ShelfName name = ShelfName.of("[SHELF]"); + SomeMessage message = SomeMessage.newBuilder().build(); + + Shelf actualResponse = + client.getShelf(name, message); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getShelfExceptionTest2() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ShelfName name = ShelfName.of("[SHELF]"); + SomeMessage message = SomeMessage.newBuilder().build(); + + client.getShelf(name, message); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getShelfTest3() { + ShelfName name2 = ShelfName.of("[SHELF]"); + String theme = "theme110327241"; + String internalTheme = "internalTheme792518087"; + Shelf expectedResponse = Shelf.newBuilder() + .setName(name2.toString()) + .setTheme(theme) + .setInternalTheme(internalTheme) + .build(); + mockService.addResponse(expectedResponse); + + ShelfName name = ShelfName.of("[SHELF]"); + SomeMessage message = SomeMessage.newBuilder().build(); + com.google.example.library.v1.StringBuilder stringBuilder = com.google.example.library.v1.StringBuilder.newBuilder().build(); + + Shelf actualResponse = + client.getShelf(name, message, stringBuilder); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getShelfExceptionTest3() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ShelfName name = ShelfName.of("[SHELF]"); + SomeMessage message = SomeMessage.newBuilder().build(); + com.google.example.library.v1.StringBuilder stringBuilder = com.google.example.library.v1.StringBuilder.newBuilder().build(); + + client.getShelf(name, message, stringBuilder); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void listShelvesTest() { + String nextPageToken = "nextPageToken-1530815211"; + ListShelvesResponse expectedResponse = ListShelvesResponse.newBuilder() + .setNextPageToken(nextPageToken) + .build(); + mockService.addResponse(expectedResponse); + + ListShelvesResponse actualResponse = + client.listShelves(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void listShelvesExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + client.listShelves(); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteShelfTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ShelfName name = ShelfName.of("[SHELF]"); + + client.deleteShelf(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void deleteShelfExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ShelfName name = ShelfName.of("[SHELF]"); + + client.deleteShelf(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void mergeShelvesTest() { + ShelfName name2 = ShelfName.of("[SHELF]"); + String theme = "theme110327241"; + String internalTheme = "internalTheme792518087"; + Shelf expectedResponse = Shelf.newBuilder() + .setName(name2.toString()) + .setTheme(theme) + .setInternalTheme(internalTheme) + .build(); + mockService.addResponse(expectedResponse); + + ShelfName name = ShelfName.of("[SHELF]"); + ShelfName otherShelfName = ShelfName.of("[SHELF]"); + + Shelf actualResponse = + client.mergeShelves(name, otherShelfName); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void mergeShelvesExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ShelfName name = ShelfName.of("[SHELF]"); + ShelfName otherShelfName = ShelfName.of("[SHELF]"); + + client.mergeShelves(name, otherShelfName); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createBookTest() { + BookName name2 = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + ReaderName reader = ReaderName.ofProjectReaderName("[PROJECT]", "[READER]"); + Book expectedResponse = Book.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .setReader(reader.toString()) + .build(); + mockService.addResponse(expectedResponse); + + ShelfName name = ShelfName.of("[SHELF]"); + Book book = Book.newBuilder().build(); + + Book actualResponse = + client.createBook(name, book); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void createBookExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ShelfName name = ShelfName.of("[SHELF]"); + Book book = Book.newBuilder().build(); + + client.createBook(name, book); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void publishSeriesTest() { + PublishSeriesResponse expectedResponse = PublishSeriesResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + Shelf shelf = Shelf.newBuilder().build(); + List books = new ArrayList<>(); + int edition = 1887963714; + SeriesUuid seriesUuid = SeriesUuid.newBuilder().build(); + PublisherName publisher = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]"); + + PublishSeriesResponse actualResponse = + client.publishSeries(shelf, books, edition, seriesUuid, publisher); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void publishSeriesExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Shelf shelf = Shelf.newBuilder().build(); + List books = new ArrayList<>(); + int edition = 1887963714; + SeriesUuid seriesUuid = SeriesUuid.newBuilder().build(); + PublisherName publisher = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]"); + + client.publishSeries(shelf, books, edition, seriesUuid, publisher); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void createInventoryTest() { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]"); + Inventory expectedResponse = Inventory.newBuilder() + .setName(name.toString()) + .build(); + mockService.addResponse(expectedResponse); + + PublisherName parent = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]"); + Inventory inventory = Inventory.newBuilder().build(); + ResourceName asset = ArchiveName.of("[ARCHIVE]"); + ResourceName parentAsset = ArchiveName.of("[ARCHIVE]"); + List assets = new ArrayList<>(); + + Inventory actualResponse = + client.createInventory(parent, inventory, asset, parentAsset, assets); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void createInventoryExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PublisherName parent = PublisherName.of("[PROJECT]", "[LOCATION]", "[PUBLISHER]"); + Inventory inventory = Inventory.newBuilder().build(); + ResourceName asset = ArchiveName.of("[ARCHIVE]"); + ResourceName parentAsset = ArchiveName.of("[ARCHIVE]"); + List assets = new ArrayList<>(); + + client.createInventory(parent, inventory, asset, parentAsset, assets); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getBookTest() { + BookName name2 = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + ReaderName reader = ReaderName.ofProjectReaderName("[PROJECT]", "[READER]"); + Book expectedResponse = Book.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .setReader(reader.toString()) + .build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + Book actualResponse = + client.getBook(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getBookExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + client.getBook(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void listBooksTest() { + String nextPageToken = ""; + Book booksElement = Book.newBuilder().build(); + List books = Arrays.asList(booksElement); + ListBooksResponse expectedResponse = ListBooksResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllBooks(books) + .build(); + mockService.addResponse(expectedResponse); + + ShelfName name = ShelfName.of("[SHELF]"); + String filter = "filter-1274492040"; + + ListBooksPagedResponse pagedListResponse = client.listBooks(name, filter); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBooksList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void listBooksExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ShelfName name = ShelfName.of("[SHELF]"); + String filter = "filter-1274492040"; + + client.listBooks(name, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void deleteBookTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + client.deleteBook(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void deleteBookExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + client.deleteBook(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateBookTest() { + BookName name2 = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + ReaderName reader = ReaderName.ofProjectReaderName("[PROJECT]", "[READER]"); + Book expectedResponse = Book.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .setReader(reader.toString()) + .build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + Book book = Book.newBuilder().build(); + + Book actualResponse = + client.updateBook(name, book); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void updateBookExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + Book book = Book.newBuilder().build(); + + client.updateBook(name, book); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateBookTest2() { + BookName name2 = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + ReaderName reader = ReaderName.ofProjectReaderName("[PROJECT]", "[READER]"); + Book expectedResponse = Book.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .setReader(reader.toString()) + .build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String optionalFoo = "optionalFoo1822578535"; + Book book = Book.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + com.google.example.library.v1.FieldMask physicalMask = com.google.example.library.v1.FieldMask.newBuilder().build(); + + Book actualResponse = + client.updateBook(name, optionalFoo, book, updateMask, physicalMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void updateBookExceptionTest2() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String optionalFoo = "optionalFoo1822578535"; + Book book = Book.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + com.google.example.library.v1.FieldMask physicalMask = com.google.example.library.v1.FieldMask.newBuilder().build(); + + client.updateBook(name, optionalFoo, book, updateMask, physicalMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void moveBookTest() { + BookName name2 = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + ReaderName reader = ReaderName.ofProjectReaderName("[PROJECT]", "[READER]"); + Book expectedResponse = Book.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .setReader(reader.toString()) + .build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + ShelfName otherShelfName = ShelfName.of("[SHELF]"); + + Book actualResponse = + client.moveBook(name, otherShelfName); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void moveBookExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + ShelfName otherShelfName = ShelfName.of("[SHELF]"); + + client.moveBook(name, otherShelfName); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void listStringsTest() { + String nextPageToken = ""; + ResourceName stringsElement = ArchiveName.of("[ARCHIVE]"); + List strings = Arrays.asList(stringsElement); + ListStringsResponse expectedResponse = ListStringsResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllStrings(UntypedResourceName.toStringList(strings)) + .build(); + mockService.addResponse(expectedResponse); + + ListStringsPagedResponse pagedListResponse = client.listStrings(); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStringsList().get(0), resources.get(0)); + List resourceNames = Lists.newArrayList(pagedListResponse.iterateAllAsResourceName()); + Assert.assertEquals(1, resourceNames.size()); + Assert.assertEquals(UntypedResourceName.parse(expectedResponse.getStringsList().get(0)), + resourceNames.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void listStringsExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + client.listStrings(); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void listStringsTest2() { + String nextPageToken = ""; + ResourceName stringsElement = ArchiveName.of("[ARCHIVE]"); + List strings = Arrays.asList(stringsElement); + ListStringsResponse expectedResponse = ListStringsResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllStrings(UntypedResourceName.toStringList(strings)) + .build(); + mockService.addResponse(expectedResponse); + + ResourceName name = ArchiveName.of("[ARCHIVE]"); + + ListStringsPagedResponse pagedListResponse = client.listStrings(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getStringsList().get(0), resources.get(0)); + List resourceNames = Lists.newArrayList(pagedListResponse.iterateAllAsResourceName()); + Assert.assertEquals(1, resourceNames.size()); + Assert.assertEquals(UntypedResourceName.parse(expectedResponse.getStringsList().get(0)), + resourceNames.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void listStringsExceptionTest2() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName name = ArchiveName.of("[ARCHIVE]"); + + client.listStrings(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void addCommentsTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + List comments = new ArrayList<>(); + + client.addComments(name, comments); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void addCommentsExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + List comments = new ArrayList<>(); + + client.addComments(name, comments); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getBookFromArchiveTest() { + ArchivedBookName name2 = ArchivedBookName.of("[ARCHIVE]", "[BOOK]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + BookFromArchive expectedResponse = BookFromArchive.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .build(); + mockService.addResponse(expectedResponse); + + ArchivedBookName name = ArchivedBookName.of("[ARCHIVE]", "[BOOK]"); + ProjectName parent = ProjectName.of("[PROJECT]"); + + BookFromArchive actualResponse = + client.getBookFromArchive(name, parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getBookFromArchiveExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ArchivedBookName name = ArchivedBookName.of("[ARCHIVE]", "[BOOK]"); + ProjectName parent = ProjectName.of("[PROJECT]"); + + client.getBookFromArchive(name, parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getBookFromAnywhereTest() { + BookName name2 = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + BookFromAnywhere expectedResponse = BookFromAnywhere.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + BookName altBookName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + LocationName place = LocationName.of("[PROJECT]", "[LOCATION]"); + FolderName folder = FolderName.of("[FOLDER]"); + + BookFromAnywhere actualResponse = + client.getBookFromAnywhere(name, altBookName, place, folder); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getBookFromAnywhereExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + BookName altBookName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + LocationName place = LocationName.of("[PROJECT]", "[LOCATION]"); + FolderName folder = FolderName.of("[FOLDER]"); + + client.getBookFromAnywhere(name, altBookName, place, folder); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getBookFromAbsolutelyAnywhereTest() { + BookName name2 = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + BookFromAnywhere expectedResponse = BookFromAnywhere.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + BookFromAnywhere actualResponse = + client.getBookFromAbsolutelyAnywhere(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getBookFromAbsolutelyAnywhereExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + client.getBookFromAbsolutelyAnywhere(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void updateBookIndexTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String indexName = "indexName746962392"; + Map indexMap = new HashMap<>(); + + client.updateBookIndex(name, indexName, indexMap); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void updateBookIndexExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String indexName = "indexName746962392"; + Map indexMap = new HashMap<>(); + + client.updateBookIndex(name, indexName, indexMap); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void findRelatedBooksTest() { + String nextPageToken = ""; + BookName namesElement = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + List names2 = Arrays.asList(namesElement); + FindRelatedBooksResponse expectedResponse = FindRelatedBooksResponse.newBuilder() + .setNextPageToken(nextPageToken) + .addAllNames(BookName.toStringList(names2)) + .build(); + mockService.addResponse(expectedResponse); + + List names = new ArrayList<>(); + List formattedShelves = new ArrayList<>(); + + FindRelatedBooksPagedResponse pagedListResponse = client.findRelatedBooks(names, formattedShelves); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getNamesList().get(0), resources.get(0)); + List resourceNames = Lists.newArrayList(pagedListResponse.iterateAllAsBookName()); + Assert.assertEquals(1, resourceNames.size()); + Assert.assertEquals(BookName.parse(expectedResponse.getNamesList().get(0)), + resourceNames.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void findRelatedBooksExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + List names = new ArrayList<>(); + List formattedShelves = new ArrayList<>(); + + client.findRelatedBooks(names, formattedShelves); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void addTagTest() { + AddTagResponse expectedResponse = AddTagResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + ResourceName resource = ArchiveName.of("[ARCHIVE]"); + String tag = "tag114586"; + + AddTagResponse actualResponse = + client.addTag(resource, tag); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void addTagExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ResourceName resource = ArchiveName.of("[ARCHIVE]"); + String tag = "tag114586"; + + client.addTag(resource, tag); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getBigBookTest() throws Exception { + BookName name2 = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + ReaderName reader = ReaderName.ofProjectReaderName("[PROJECT]", "[READER]"); + Book expectedResponse = Book.newBuilder() + .setName(name2.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .setReader(reader.toString()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("getBigBookTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockLibraryService.addResponse(resultOperation); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + Book actualResponse = + client.getBigBookAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getBigBookExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + client.getBigBookAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + + @Test + @SuppressWarnings("all") + public void getBigNothingTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("getBigNothingTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockLibraryService.addResponse(resultOperation); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + Empty actualResponse = + client.getBigNothingAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getBigNothingExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + + client.getBigNothingAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + + @Test + @SuppressWarnings("all") + public void moveBooksTest() { + boolean success = false; + MoveBooksResponse expectedResponse = MoveBooksResponse.newBuilder() + .setSuccess(success) + .build(); + mockService.addResponse(expectedResponse); + + ArchiveName source = ArchiveName.of("[ARCHIVE]"); + ArchiveName destination = ArchiveName.of("[ARCHIVE]"); + List formattedPublishers = new ArrayList<>(); + ProjectName project = ProjectName.of("[PROJECT]"); + + MoveBooksResponse actualResponse = + client.moveBooks(source, destination, formattedPublishers, project); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void moveBooksExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ArchiveName source = ArchiveName.of("[ARCHIVE]"); + ArchiveName destination = ArchiveName.of("[ARCHIVE]"); + List formattedPublishers = new ArrayList<>(); + ProjectName project = ProjectName.of("[PROJECT]"); + + client.moveBooks(source, destination, formattedPublishers, project); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void archiveBooksTest() { + boolean success = false; + ArchiveBooksResponse expectedResponse = ArchiveBooksResponse.newBuilder() + .setSuccess(success) + .build(); + mockService.addResponse(expectedResponse); + + ArchiveName source = ArchiveName.of("[ARCHIVE]"); + ArchiveName archive = ArchiveName.of("[ARCHIVE]"); + + ArchiveBooksResponse actualResponse = + client.archiveBooks(source, archive); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void archiveBooksExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ArchiveName source = ArchiveName.of("[ARCHIVE]"); + ArchiveName archive = ArchiveName.of("[ARCHIVE]"); + + client.archiveBooks(source, archive); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void longRunningArchiveBooksTest() throws Exception { + boolean success = false; + ArchiveBooksResponse expectedResponse = ArchiveBooksResponse.newBuilder() + .setSuccess(success) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("longRunningArchiveBooksTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockLibraryService.addResponse(resultOperation); + + ArchiveName source = ArchiveName.of("[ARCHIVE]"); + ArchiveName archive = ArchiveName.of("[ARCHIVE]"); + + ArchiveBooksResponse actualResponse = + client.longRunningArchiveBooksAsync(source, archive).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void longRunningArchiveBooksExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ArchiveName source = ArchiveName.of("[ARCHIVE]"); + ArchiveName archive = ArchiveName.of("[ARCHIVE]"); + + client.longRunningArchiveBooksAsync(source, archive).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); + InvalidArgumentException apiException = (InvalidArgumentException) e.getCause(); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + + @Test + @SuppressWarnings("all") + public void saveBookTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + Book.Rating rating = Book.Rating.GOOD; + + client.saveBook(name, author, title, rating); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void saveBookExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + Book.Rating rating = Book.Rating.GOOD; + + client.saveBook(name, author, title, rating); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void testOptionalRequiredFlatteningParamsTest() { + TestOptionalRequiredFlatteningParamsResponse expectedResponse = TestOptionalRequiredFlatteningParamsResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + TestOptionalRequiredFlatteningParamsResponse actualResponse = + client.testOptionalRequiredFlatteningParams(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void testOptionalRequiredFlatteningParamsExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + client.testOptionalRequiredFlatteningParams(); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void testOptionalRequiredFlatteningParamsTest2() { + TestOptionalRequiredFlatteningParamsResponse expectedResponse = TestOptionalRequiredFlatteningParamsResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + int requiredSingularInt32 = 72313594; + long requiredSingularInt64 = 72313499L; + float requiredSingularFloat = -7514705.0F; + double requiredSingularDouble = 1.9111005E8; + boolean requiredSingularBool = true; + TestOptionalRequiredFlatteningParamsRequest.InnerEnum requiredSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO; + String requiredSingularString = "requiredSingularString-1949894503"; + ByteString requiredSingularBytes = ByteString.copyFromUtf8("-29"); + TestOptionalRequiredFlatteningParamsRequest.InnerMessage requiredSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build(); + BookName requiredSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + BookName requiredSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String requiredSingularResourceNameCommon = "requiredSingularResourceNameCommon-1126805002"; + int requiredSingularFixed32 = 720656715; + long requiredSingularFixed64 = 720656810; + List requiredRepeatedInt32 = new ArrayList<>(); + List requiredRepeatedInt64 = new ArrayList<>(); + List requiredRepeatedFloat = new ArrayList<>(); + List requiredRepeatedDouble = new ArrayList<>(); + List requiredRepeatedBool = new ArrayList<>(); + List requiredRepeatedEnum = new ArrayList<>(); + List requiredRepeatedString = new ArrayList<>(); + List requiredRepeatedBytes = new ArrayList<>(); + List requiredRepeatedMessage = new ArrayList<>(); + List requiredRepeatedResourceName = new ArrayList<>(); + List requiredRepeatedResourceNameOneof = new ArrayList<>(); + List requiredRepeatedResourceNameCommon = new ArrayList<>(); + List requiredRepeatedFixed32 = new ArrayList<>(); + List requiredRepeatedFixed64 = new ArrayList<>(); + Map requiredMap = new HashMap<>(); + Any requiredAnyValue = Any.newBuilder().build(); + Struct requiredStructValue = Struct.newBuilder().build(); + Value requiredValueValue = Value.newBuilder().build(); + ListValue requiredListValueValue = ListValue.newBuilder().build(); + Timestamp requiredTimeValue = Timestamp.newBuilder().build(); + Duration requiredDurationValue = Duration.newBuilder().build(); + FieldMask requiredFieldMaskValue = FieldMask.newBuilder().build(); + Int32Value requiredInt32Value = Int32Value.newBuilder().build(); + UInt32Value requiredUint32Value = UInt32Value.newBuilder().build(); + Int64Value requiredInt64Value = Int64Value.newBuilder().build(); + UInt64Value requiredUint64Value = UInt64Value.newBuilder().build(); + FloatValue requiredFloatValue = FloatValue.newBuilder().build(); + DoubleValue requiredDoubleValue = DoubleValue.newBuilder().build(); + StringValue requiredStringValue = StringValue.newBuilder().build(); + BoolValue requiredBoolValue = BoolValue.newBuilder().build(); + BytesValue requiredBytesValue = BytesValue.newBuilder().build(); + List requiredRepeatedAnyValue = new ArrayList<>(); + List requiredRepeatedStructValue = new ArrayList<>(); + List requiredRepeatedValueValue = new ArrayList<>(); + List requiredRepeatedListValueValue = new ArrayList<>(); + List requiredRepeatedTimeValue = new ArrayList<>(); + List requiredRepeatedDurationValue = new ArrayList<>(); + List requiredRepeatedFieldMaskValue = new ArrayList<>(); + List requiredRepeatedInt32Value = new ArrayList<>(); + List requiredRepeatedUint32Value = new ArrayList<>(); + List requiredRepeatedInt64Value = new ArrayList<>(); + List requiredRepeatedUint64Value = new ArrayList<>(); + List requiredRepeatedFloatValue = new ArrayList<>(); + List requiredRepeatedDoubleValue = new ArrayList<>(); + List requiredRepeatedStringValue = new ArrayList<>(); + List requiredRepeatedBoolValue = new ArrayList<>(); + List requiredRepeatedBytesValue = new ArrayList<>(); + int optionalSingularInt32 = 1196565723; + long optionalSingularInt64 = 1196565628L; + float optionalSingularFloat = -1.19939918E8F; + double optionalSingularDouble = 1.41902287E8; + boolean optionalSingularBool = false; + TestOptionalRequiredFlatteningParamsRequest.InnerEnum optionalSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO; + String optionalSingularString = "optionalSingularString1852995162"; + ByteString optionalSingularBytes = ByteString.copyFromUtf8("2"); + TestOptionalRequiredFlatteningParamsRequest.InnerMessage optionalSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build(); + BookName optionalSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + BookName optionalSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String optionalSingularResourceNameCommon = "optionalSingularResourceNameCommon-108123657"; + int optionalSingularFixed32 = 1648847958; + long optionalSingularFixed64 = 1648847863; + List optionalRepeatedInt32 = new ArrayList<>(); + List optionalRepeatedInt64 = new ArrayList<>(); + List optionalRepeatedFloat = new ArrayList<>(); + List optionalRepeatedDouble = new ArrayList<>(); + List optionalRepeatedBool = new ArrayList<>(); + List optionalRepeatedEnum = new ArrayList<>(); + List optionalRepeatedString = new ArrayList<>(); + List optionalRepeatedBytes = new ArrayList<>(); + List optionalRepeatedMessage = new ArrayList<>(); + List optionalRepeatedResourceName = new ArrayList<>(); + List optionalRepeatedResourceNameOneof = new ArrayList<>(); + List optionalRepeatedResourceNameCommon = new ArrayList<>(); + List optionalRepeatedFixed32 = new ArrayList<>(); + List optionalRepeatedFixed64 = new ArrayList<>(); + Map optionalMap = new HashMap<>(); + Any anyValue = Any.newBuilder().build(); + Struct structValue = Struct.newBuilder().build(); + Value valueValue = Value.newBuilder().build(); + ListValue listValueValue = ListValue.newBuilder().build(); + Timestamp timeValue = Timestamp.newBuilder().build(); + Duration durationValue = Duration.newBuilder().build(); + FieldMask fieldMaskValue = FieldMask.newBuilder().build(); + Int32Value int32Value = Int32Value.newBuilder().build(); + UInt32Value uint32Value = UInt32Value.newBuilder().build(); + Int64Value int64Value = Int64Value.newBuilder().build(); + UInt64Value uint64Value = UInt64Value.newBuilder().build(); + FloatValue floatValue = FloatValue.newBuilder().build(); + DoubleValue doubleValue = DoubleValue.newBuilder().build(); + StringValue stringValue = StringValue.newBuilder().build(); + BoolValue boolValue = BoolValue.newBuilder().build(); + BytesValue bytesValue = BytesValue.newBuilder().build(); + List repeatedAnyValue = new ArrayList<>(); + List repeatedStructValue = new ArrayList<>(); + List repeatedValueValue = new ArrayList<>(); + List repeatedListValueValue = new ArrayList<>(); + List repeatedTimeValue = new ArrayList<>(); + List repeatedDurationValue = new ArrayList<>(); + List repeatedFieldMaskValue = new ArrayList<>(); + List repeatedInt32Value = new ArrayList<>(); + List repeatedUint32Value = new ArrayList<>(); + List repeatedInt64Value = new ArrayList<>(); + List repeatedUint64Value = new ArrayList<>(); + List repeatedFloatValue = new ArrayList<>(); + List repeatedDoubleValue = new ArrayList<>(); + List repeatedStringValue = new ArrayList<>(); + List repeatedBoolValue = new ArrayList<>(); + List repeatedBytesValue = new ArrayList<>(); + + TestOptionalRequiredFlatteningParamsResponse actualResponse = + client.testOptionalRequiredFlatteningParams(requiredSingularInt32, requiredSingularInt64, requiredSingularFloat, requiredSingularDouble, requiredSingularBool, requiredSingularEnum, requiredSingularString, requiredSingularBytes, requiredSingularMessage, requiredSingularResourceName, requiredSingularResourceNameOneof, requiredSingularResourceNameCommon, requiredSingularFixed32, requiredSingularFixed64, requiredRepeatedInt32, requiredRepeatedInt64, requiredRepeatedFloat, requiredRepeatedDouble, requiredRepeatedBool, requiredRepeatedEnum, requiredRepeatedString, requiredRepeatedBytes, requiredRepeatedMessage, requiredRepeatedResourceName, requiredRepeatedResourceNameOneof, requiredRepeatedResourceNameCommon, requiredRepeatedFixed32, requiredRepeatedFixed64, requiredMap, requiredAnyValue, requiredStructValue, requiredValueValue, requiredListValueValue, requiredTimeValue, requiredDurationValue, requiredFieldMaskValue, requiredInt32Value, requiredUint32Value, requiredInt64Value, requiredUint64Value, requiredFloatValue, requiredDoubleValue, requiredStringValue, requiredBoolValue, requiredBytesValue, requiredRepeatedAnyValue, requiredRepeatedStructValue, requiredRepeatedValueValue, requiredRepeatedListValueValue, requiredRepeatedTimeValue, requiredRepeatedDurationValue, requiredRepeatedFieldMaskValue, requiredRepeatedInt32Value, requiredRepeatedUint32Value, requiredRepeatedInt64Value, requiredRepeatedUint64Value, requiredRepeatedFloatValue, requiredRepeatedDoubleValue, requiredRepeatedStringValue, requiredRepeatedBoolValue, requiredRepeatedBytesValue, optionalSingularInt32, optionalSingularInt64, optionalSingularFloat, optionalSingularDouble, optionalSingularBool, optionalSingularEnum, optionalSingularString, optionalSingularBytes, optionalSingularMessage, optionalSingularResourceName, optionalSingularResourceNameOneof, optionalSingularResourceNameCommon, optionalSingularFixed32, optionalSingularFixed64, optionalRepeatedInt32, optionalRepeatedInt64, optionalRepeatedFloat, optionalRepeatedDouble, optionalRepeatedBool, optionalRepeatedEnum, optionalRepeatedString, optionalRepeatedBytes, optionalRepeatedMessage, optionalRepeatedResourceName, optionalRepeatedResourceNameOneof, optionalRepeatedResourceNameCommon, optionalRepeatedFixed32, optionalRepeatedFixed64, optionalMap, anyValue, structValue, valueValue, listValueValue, timeValue, durationValue, fieldMaskValue, int32Value, uint32Value, int64Value, uint64Value, floatValue, doubleValue, stringValue, boolValue, bytesValue, repeatedAnyValue, repeatedStructValue, repeatedValueValue, repeatedListValueValue, repeatedTimeValue, repeatedDurationValue, repeatedFieldMaskValue, repeatedInt32Value, repeatedUint32Value, repeatedInt64Value, repeatedUint64Value, repeatedFloatValue, repeatedDoubleValue, repeatedStringValue, repeatedBoolValue, repeatedBytesValue); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void testOptionalRequiredFlatteningParamsExceptionTest2() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + int requiredSingularInt32 = 72313594; + long requiredSingularInt64 = 72313499L; + float requiredSingularFloat = -7514705.0F; + double requiredSingularDouble = 1.9111005E8; + boolean requiredSingularBool = true; + TestOptionalRequiredFlatteningParamsRequest.InnerEnum requiredSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO; + String requiredSingularString = "requiredSingularString-1949894503"; + ByteString requiredSingularBytes = ByteString.copyFromUtf8("-29"); + TestOptionalRequiredFlatteningParamsRequest.InnerMessage requiredSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build(); + BookName requiredSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + BookName requiredSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String requiredSingularResourceNameCommon = "requiredSingularResourceNameCommon-1126805002"; + int requiredSingularFixed32 = 720656715; + long requiredSingularFixed64 = 720656810; + List requiredRepeatedInt32 = new ArrayList<>(); + List requiredRepeatedInt64 = new ArrayList<>(); + List requiredRepeatedFloat = new ArrayList<>(); + List requiredRepeatedDouble = new ArrayList<>(); + List requiredRepeatedBool = new ArrayList<>(); + List requiredRepeatedEnum = new ArrayList<>(); + List requiredRepeatedString = new ArrayList<>(); + List requiredRepeatedBytes = new ArrayList<>(); + List requiredRepeatedMessage = new ArrayList<>(); + List requiredRepeatedResourceName = new ArrayList<>(); + List requiredRepeatedResourceNameOneof = new ArrayList<>(); + List requiredRepeatedResourceNameCommon = new ArrayList<>(); + List requiredRepeatedFixed32 = new ArrayList<>(); + List requiredRepeatedFixed64 = new ArrayList<>(); + Map requiredMap = new HashMap<>(); + Any requiredAnyValue = Any.newBuilder().build(); + Struct requiredStructValue = Struct.newBuilder().build(); + Value requiredValueValue = Value.newBuilder().build(); + ListValue requiredListValueValue = ListValue.newBuilder().build(); + Timestamp requiredTimeValue = Timestamp.newBuilder().build(); + Duration requiredDurationValue = Duration.newBuilder().build(); + FieldMask requiredFieldMaskValue = FieldMask.newBuilder().build(); + Int32Value requiredInt32Value = Int32Value.newBuilder().build(); + UInt32Value requiredUint32Value = UInt32Value.newBuilder().build(); + Int64Value requiredInt64Value = Int64Value.newBuilder().build(); + UInt64Value requiredUint64Value = UInt64Value.newBuilder().build(); + FloatValue requiredFloatValue = FloatValue.newBuilder().build(); + DoubleValue requiredDoubleValue = DoubleValue.newBuilder().build(); + StringValue requiredStringValue = StringValue.newBuilder().build(); + BoolValue requiredBoolValue = BoolValue.newBuilder().build(); + BytesValue requiredBytesValue = BytesValue.newBuilder().build(); + List requiredRepeatedAnyValue = new ArrayList<>(); + List requiredRepeatedStructValue = new ArrayList<>(); + List requiredRepeatedValueValue = new ArrayList<>(); + List requiredRepeatedListValueValue = new ArrayList<>(); + List requiredRepeatedTimeValue = new ArrayList<>(); + List requiredRepeatedDurationValue = new ArrayList<>(); + List requiredRepeatedFieldMaskValue = new ArrayList<>(); + List requiredRepeatedInt32Value = new ArrayList<>(); + List requiredRepeatedUint32Value = new ArrayList<>(); + List requiredRepeatedInt64Value = new ArrayList<>(); + List requiredRepeatedUint64Value = new ArrayList<>(); + List requiredRepeatedFloatValue = new ArrayList<>(); + List requiredRepeatedDoubleValue = new ArrayList<>(); + List requiredRepeatedStringValue = new ArrayList<>(); + List requiredRepeatedBoolValue = new ArrayList<>(); + List requiredRepeatedBytesValue = new ArrayList<>(); + int optionalSingularInt32 = 1196565723; + long optionalSingularInt64 = 1196565628L; + float optionalSingularFloat = -1.19939918E8F; + double optionalSingularDouble = 1.41902287E8; + boolean optionalSingularBool = false; + TestOptionalRequiredFlatteningParamsRequest.InnerEnum optionalSingularEnum = TestOptionalRequiredFlatteningParamsRequest.InnerEnum.ZERO; + String optionalSingularString = "optionalSingularString1852995162"; + ByteString optionalSingularBytes = ByteString.copyFromUtf8("2"); + TestOptionalRequiredFlatteningParamsRequest.InnerMessage optionalSingularMessage = TestOptionalRequiredFlatteningParamsRequest.InnerMessage.newBuilder().build(); + BookName optionalSingularResourceName = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + BookName optionalSingularResourceNameOneof = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String optionalSingularResourceNameCommon = "optionalSingularResourceNameCommon-108123657"; + int optionalSingularFixed32 = 1648847958; + long optionalSingularFixed64 = 1648847863; + List optionalRepeatedInt32 = new ArrayList<>(); + List optionalRepeatedInt64 = new ArrayList<>(); + List optionalRepeatedFloat = new ArrayList<>(); + List optionalRepeatedDouble = new ArrayList<>(); + List optionalRepeatedBool = new ArrayList<>(); + List optionalRepeatedEnum = new ArrayList<>(); + List optionalRepeatedString = new ArrayList<>(); + List optionalRepeatedBytes = new ArrayList<>(); + List optionalRepeatedMessage = new ArrayList<>(); + List optionalRepeatedResourceName = new ArrayList<>(); + List optionalRepeatedResourceNameOneof = new ArrayList<>(); + List optionalRepeatedResourceNameCommon = new ArrayList<>(); + List optionalRepeatedFixed32 = new ArrayList<>(); + List optionalRepeatedFixed64 = new ArrayList<>(); + Map optionalMap = new HashMap<>(); + Any anyValue = Any.newBuilder().build(); + Struct structValue = Struct.newBuilder().build(); + Value valueValue = Value.newBuilder().build(); + ListValue listValueValue = ListValue.newBuilder().build(); + Timestamp timeValue = Timestamp.newBuilder().build(); + Duration durationValue = Duration.newBuilder().build(); + FieldMask fieldMaskValue = FieldMask.newBuilder().build(); + Int32Value int32Value = Int32Value.newBuilder().build(); + UInt32Value uint32Value = UInt32Value.newBuilder().build(); + Int64Value int64Value = Int64Value.newBuilder().build(); + UInt64Value uint64Value = UInt64Value.newBuilder().build(); + FloatValue floatValue = FloatValue.newBuilder().build(); + DoubleValue doubleValue = DoubleValue.newBuilder().build(); + StringValue stringValue = StringValue.newBuilder().build(); + BoolValue boolValue = BoolValue.newBuilder().build(); + BytesValue bytesValue = BytesValue.newBuilder().build(); + List repeatedAnyValue = new ArrayList<>(); + List repeatedStructValue = new ArrayList<>(); + List repeatedValueValue = new ArrayList<>(); + List repeatedListValueValue = new ArrayList<>(); + List repeatedTimeValue = new ArrayList<>(); + List repeatedDurationValue = new ArrayList<>(); + List repeatedFieldMaskValue = new ArrayList<>(); + List repeatedInt32Value = new ArrayList<>(); + List repeatedUint32Value = new ArrayList<>(); + List repeatedInt64Value = new ArrayList<>(); + List repeatedUint64Value = new ArrayList<>(); + List repeatedFloatValue = new ArrayList<>(); + List repeatedDoubleValue = new ArrayList<>(); + List repeatedStringValue = new ArrayList<>(); + List repeatedBoolValue = new ArrayList<>(); + List repeatedBytesValue = new ArrayList<>(); + + client.testOptionalRequiredFlatteningParams(requiredSingularInt32, requiredSingularInt64, requiredSingularFloat, requiredSingularDouble, requiredSingularBool, requiredSingularEnum, requiredSingularString, requiredSingularBytes, requiredSingularMessage, requiredSingularResourceName, requiredSingularResourceNameOneof, requiredSingularResourceNameCommon, requiredSingularFixed32, requiredSingularFixed64, requiredRepeatedInt32, requiredRepeatedInt64, requiredRepeatedFloat, requiredRepeatedDouble, requiredRepeatedBool, requiredRepeatedEnum, requiredRepeatedString, requiredRepeatedBytes, requiredRepeatedMessage, requiredRepeatedResourceName, requiredRepeatedResourceNameOneof, requiredRepeatedResourceNameCommon, requiredRepeatedFixed32, requiredRepeatedFixed64, requiredMap, requiredAnyValue, requiredStructValue, requiredValueValue, requiredListValueValue, requiredTimeValue, requiredDurationValue, requiredFieldMaskValue, requiredInt32Value, requiredUint32Value, requiredInt64Value, requiredUint64Value, requiredFloatValue, requiredDoubleValue, requiredStringValue, requiredBoolValue, requiredBytesValue, requiredRepeatedAnyValue, requiredRepeatedStructValue, requiredRepeatedValueValue, requiredRepeatedListValueValue, requiredRepeatedTimeValue, requiredRepeatedDurationValue, requiredRepeatedFieldMaskValue, requiredRepeatedInt32Value, requiredRepeatedUint32Value, requiredRepeatedInt64Value, requiredRepeatedUint64Value, requiredRepeatedFloatValue, requiredRepeatedDoubleValue, requiredRepeatedStringValue, requiredRepeatedBoolValue, requiredRepeatedBytesValue, optionalSingularInt32, optionalSingularInt64, optionalSingularFloat, optionalSingularDouble, optionalSingularBool, optionalSingularEnum, optionalSingularString, optionalSingularBytes, optionalSingularMessage, optionalSingularResourceName, optionalSingularResourceNameOneof, optionalSingularResourceNameCommon, optionalSingularFixed32, optionalSingularFixed64, optionalRepeatedInt32, optionalRepeatedInt64, optionalRepeatedFloat, optionalRepeatedDouble, optionalRepeatedBool, optionalRepeatedEnum, optionalRepeatedString, optionalRepeatedBytes, optionalRepeatedMessage, optionalRepeatedResourceName, optionalRepeatedResourceNameOneof, optionalRepeatedResourceNameCommon, optionalRepeatedFixed32, optionalRepeatedFixed64, optionalMap, anyValue, structValue, valueValue, listValueValue, timeValue, durationValue, fieldMaskValue, int32Value, uint32Value, int64Value, uint64Value, floatValue, doubleValue, stringValue, boolValue, bytesValue, repeatedAnyValue, repeatedStructValue, repeatedValueValue, repeatedListValueValue, repeatedTimeValue, repeatedDurationValue, repeatedFieldMaskValue, repeatedInt32Value, repeatedUint32Value, repeatedInt64Value, repeatedUint64Value, repeatedFloatValue, repeatedDoubleValue, repeatedStringValue, repeatedBoolValue, repeatedBytesValue); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void privateListShelvesTest() { + BookName name = BookName.ofShelfBookOneBookTwoName("[SHELF]", "[BOOK_ONE]", "[BOOK_TWO]"); + String author = "author-1406328437"; + String title = "title110371416"; + boolean read = true; + ReaderName reader = ReaderName.ofProjectReaderName("[PROJECT]", "[READER]"); + Book expectedResponse = Book.newBuilder() + .setName(name.toString()) + .setAuthor(author) + .setTitle(title) + .setRead(read) + .setReader(reader.toString()) + .build(); + mockService.addResponse(expectedResponse); + + Book actualResponse = + client.privateListShelves(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void privateListShelvesExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + client.privateListShelves(); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + +} +============== file: src/test/java/com/google/example/library/v1/MyProtoClientTest.java ============== +/* + * 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.example.library.v1; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode.Code; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import static com.google.example.library.v1.stub.HttpJsonMyProtoStub.getNamespaceMethodDescriptor; +import static com.google.example.library.v1.stub.HttpJsonMyProtoStub.myMethodMethodDescriptor; +import com.google.example.library.v1.stub.MyProtoStubSettings; +import com.google.protos.google.example.library.v1.AnotherService.MethodRequest; +import com.google.protos.google.example.library.v1.AnotherService.MethodResponse; +import com.google.protos.google.example.library.v1.AnotherService.Namespace; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +@javax.annotation.Generated("by GAPIC") +public class MyProtoClientTest { + private static final List METHOD_DESCRIPTORS = ImmutableList.copyOf( + Lists.newArrayList( + myMethodMethodDescriptor, + getNamespaceMethodDescriptor + )); + private static final MockHttpService mockService + = new MockHttpService(METHOD_DESCRIPTORS, MyProtoStubSettings.getDefaultEndpoint()); + + private static MyProtoClient client; + private static MyProtoSettings clientSettings; + + @BeforeClass + public static void setUp() throws IOException { + clientSettings = + MyProtoSettings.newBuilder() + .setTransportChannelProvider( + MyProtoSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService).build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = + MyProtoClient.create(clientSettings); + } + + @After + public void cleanUp() { + mockService.reset(); + } + + @AfterClass + public static void tearDown() throws Exception { + client.close(); + } + + @Test + @SuppressWarnings("all") + public void myMethodTest() { + String myfield = "myfield1515208398"; + MethodResponse expectedResponse = MethodResponse.newBuilder() + .setMyfield(myfield) + .build(); + mockService.addResponse(expectedResponse); + + MethodRequest request = MethodRequest.newBuilder().build(); + + MethodResponse actualResponse = + client.myMethod(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void myMethodExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + MethodRequest request = MethodRequest.newBuilder().build(); + + client.myMethod(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + + @Test + @SuppressWarnings("all") + public void getNamespaceTest() { + String value = "value111972721"; + Namespace expectedResponse = Namespace.newBuilder() + .setValue(value) + .build(); + mockService.addResponse(expectedResponse); + + MethodRequest request = MethodRequest.newBuilder().build(); + + Namespace actualResponse = + client.getNamespace(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = mockService.getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()).iterator().next(); + Assert.assertTrue(GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey).matches()); + } + + @Test + @SuppressWarnings("all") + public void getNamespaceExceptionTest() throws Exception { + ApiException exception = ApiExceptionFactory.createException(new Exception(), FakeStatusCode.of(Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + MethodRequest request = MethodRequest.newBuilder().build(); + + client.getNamespace(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + +} diff --git a/src/test/java/com/google/api/codegen/protoannotations/testdata/php_library.baseline b/src/test/java/com/google/api/codegen/protoannotations/testdata/php_library.baseline index 8a1e687e4a..27c87cee8c 100644 --- a/src/test/java/com/google/api/codegen/protoannotations/testdata/php_library.baseline +++ b/src/test/java/com/google/api/codegen/protoannotations/testdata/php_library.baseline @@ -6418,7 +6418,7 @@ return [ ], 'DeleteShelf' => [ 'method' => 'delete', - 'uriTemplate' => '/v1/{name=bookShelves/*}', + 'uriTemplate' => '/v1/bookShelves/{name}', 'placeholders' => [ 'name' => [ 'getters' => [ diff --git a/src/test/java/com/google/api/codegen/protoannotations/testdata/php_library_with_grpc_service_config.baseline b/src/test/java/com/google/api/codegen/protoannotations/testdata/php_library_with_grpc_service_config.baseline index 0126cbc0fa..2862c361f7 100644 --- a/src/test/java/com/google/api/codegen/protoannotations/testdata/php_library_with_grpc_service_config.baseline +++ b/src/test/java/com/google/api/codegen/protoannotations/testdata/php_library_with_grpc_service_config.baseline @@ -6437,7 +6437,7 @@ return [ ], 'DeleteShelf' => [ 'method' => 'delete', - 'uriTemplate' => '/v1/{name=bookShelves/*}', + 'uriTemplate' => '/v1/bookShelves/{name}', 'placeholders' => [ 'name' => [ 'getters' => [ diff --git a/src/test/java/com/google/api/codegen/testsrc/protoannotations/library.proto b/src/test/java/com/google/api/codegen/testsrc/protoannotations/library.proto index 16c2077630..fb941c4d7a 100644 --- a/src/test/java/com/google/api/codegen/testsrc/protoannotations/library.proto +++ b/src/test/java/com/google/api/codegen/testsrc/protoannotations/library.proto @@ -86,7 +86,7 @@ service LibraryService { // Deletes a shelf. rpc DeleteShelf(DeleteShelfRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { delete: "/v1/{name=bookShelves/*}" }; + option (google.api.http) = { delete: "/v1/bookShelves/{name}" }; option (google.api.method_signature) = "name"; }