diff --git a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Api.java b/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Api.java
deleted file mode 100644
index 8352fff2b838..000000000000
--- a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Api.java
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.logging.spi.v2;
-
-import com.google.api.gax.core.PageAccessor;
-import com.google.api.gax.grpc.ApiCallable;
-import com.google.api.gax.protobuf.PathTemplate;
-import com.google.logging.v2.CreateSinkRequest;
-import com.google.logging.v2.DeleteSinkRequest;
-import com.google.logging.v2.GetSinkRequest;
-import com.google.logging.v2.ListSinksRequest;
-import com.google.logging.v2.ListSinksResponse;
-import com.google.logging.v2.LogSink;
-import com.google.logging.v2.UpdateSinkRequest;
-import com.google.protobuf.Empty;
-import io.grpc.ManagedChannel;
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-
-// AUTO-GENERATED DOCUMENTATION AND SERVICE
-/**
- * Service Description: Service for configuring sinks used to export log entries outside Stackdriver
- * Logging.
- *
- *
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 (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * LogSink response = configServiceV2Api.getSink(formattedSinkName);
- * }
- *
- *
- *
- * Note: close() needs to be called on the configServiceV2Api 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:
- *
- *
- * - 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.
- *
- 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.
- *
- A "callable" method. This type of method takes no parameters and returns an immutable
- * ApiCallable 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 ConfigServiceV2Settings to
- * create(). For example:
- *
- *
- *
- * ConfigServiceV2Settings configServiceV2Settings = ConfigServiceV2Settings.defaultBuilder()
- * .provideChannelWith(myCredentials)
- * .build();
- * ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create(configServiceV2Settings);
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class ConfigServiceV2Api implements AutoCloseable {
- private final ConfigServiceV2Settings settings;
- private final ManagedChannel channel;
- private final ScheduledExecutorService executor;
- private final List closeables = new ArrayList<>();
-
- private final ApiCallable listSinksCallable;
- private final ApiCallable> listSinksPagedCallable;
- private final ApiCallable getSinkCallable;
- private final ApiCallable createSinkCallable;
- private final ApiCallable updateSinkCallable;
- private final ApiCallable deleteSinkCallable;
-
- public final ConfigServiceV2Settings getSettings() {
- return settings;
- }
-
- private static final PathTemplate PARENT_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}");
-
- private static final PathTemplate SINK_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/sinks/{sink}");
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a parent resource.
- */
- public static final String formatParentName(String project) {
- return PARENT_PATH_TEMPLATE.instantiate("project", project);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a sink resource.
- */
- public static final String formatSinkName(String project, String sink) {
- return SINK_PATH_TEMPLATE.instantiate(
- "project", project,
- "sink", sink);
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a parent resource.
- */
- public static final String parseProjectFromParentName(String parentName) {
- return PARENT_PATH_TEMPLATE.parse(parentName).get("project");
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a sink resource.
- */
- public static final String parseProjectFromSinkName(String sinkName) {
- return SINK_PATH_TEMPLATE.parse(sinkName).get("project");
- }
-
- /**
- * Parses the sink from the given fully-qualified path which
- * represents a sink resource.
- */
- public static final String parseSinkFromSinkName(String sinkName) {
- return SINK_PATH_TEMPLATE.parse(sinkName).get("sink");
- }
-
- /**
- * Constructs an instance of ConfigServiceV2Api with default settings.
- */
- public static final ConfigServiceV2Api create() throws IOException {
- return create(ConfigServiceV2Settings.defaultBuilder().build());
- }
-
- /**
- * Constructs an instance of ConfigServiceV2Api, 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 ConfigServiceV2Api create(ConfigServiceV2Settings settings)
- throws IOException {
- return new ConfigServiceV2Api(settings);
- }
-
- /**
- * Constructs an instance of ConfigServiceV2Api, using the given settings.
- * This is protected so that it easy to make a subclass, but otherwise, the static
- * factory methods should be preferred.
- */
- protected ConfigServiceV2Api(ConfigServiceV2Settings settings) throws IOException {
- this.settings = settings;
- this.executor = settings.getExecutorProvider().getOrBuildExecutor();
- this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
-
- this.listSinksCallable =
- ApiCallable.create(settings.listSinksSettings(), this.channel, this.executor);
- this.listSinksPagedCallable =
- ApiCallable.createPagedVariant(settings.listSinksSettings(), this.channel, this.executor);
- this.getSinkCallable =
- ApiCallable.create(settings.getSinkSettings(), this.channel, this.executor);
- this.createSinkCallable =
- ApiCallable.create(settings.createSinkSettings(), this.channel, this.executor);
- this.updateSinkCallable =
- ApiCallable.create(settings.updateSinkSettings(), this.channel, this.executor);
- this.deleteSinkCallable =
- ApiCallable.create(settings.deleteSinkSettings(), this.channel, this.executor);
-
- if (settings.getChannelProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- channel.shutdown();
- }
- });
- }
- if (settings.getExecutorProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- executor.shutdown();
- }
- });
- }
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists sinks.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
- * for (LogSink element : configServiceV2Api.listSinks(formattedParent)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param parent Required. The resource name containing the sinks.
- * Example: `"projects/my-logging-project"`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listSinks(String parent) {
- PARENT_PATH_TEMPLATE.validate(parent, "listSinks");
- ListSinksRequest request = ListSinksRequest.newBuilder().setParent(parent).build();
- return listSinks(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists sinks.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
- * ListSinksRequest request = ListSinksRequest.newBuilder()
- * .setParent(formattedParent)
- * .build();
- * for (LogSink element : configServiceV2Api.listSinks(request)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listSinks(ListSinksRequest request) {
- return listSinksPagedCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists sinks.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
- * ListSinksRequest request = ListSinksRequest.newBuilder()
- * .setParent(formattedParent)
- * .build();
- * ListenableFuture<PageAccessor<LogSink>> future = configServiceV2Api.listSinksPagedCallable().futureCall(request);
- * // Do something
- * for (LogSink element : future.get()) {
- * // doThingsWith(element);
- * }
- * }
- *
- */
- public final ApiCallable> listSinksPagedCallable() {
- return listSinksPagedCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists sinks.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
- * ListSinksRequest request = ListSinksRequest.newBuilder()
- * .setParent(formattedParent)
- * .build();
- * while (true) {
- * ListSinksResponse response = configServiceV2Api.listSinksCallable().call(request);
- * for (LogSink element : response.getSinksList()) {
- * // doThingsWith(element);
- * }
- * String nextPageToken = response.getNextPageToken();
- * if (!Strings.isNullOrEmpty(nextPageToken)) {
- * request = request.toBuilder().setPageToken(nextPageToken).build();
- * } else {
- * break;
- * }
- * }
- * }
- *
- */
- public final ApiCallable listSinksCallable() {
- return listSinksCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * LogSink response = configServiceV2Api.getSink(formattedSinkName);
- * }
- *
- *
- * @param sinkName The resource name of the sink to return.
- * Example: `"projects/my-project-id/sinks/my-sink-id"`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogSink getSink(String sinkName) {
- SINK_PATH_TEMPLATE.validate(sinkName, "getSink");
- GetSinkRequest request = GetSinkRequest.newBuilder().setSinkName(sinkName).build();
- return getSink(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * GetSinkRequest request = GetSinkRequest.newBuilder()
- * .setSinkName(formattedSinkName)
- * .build();
- * LogSink response = configServiceV2Api.getSink(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final LogSink getSink(GetSinkRequest request) {
- return getSinkCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * GetSinkRequest request = GetSinkRequest.newBuilder()
- * .setSinkName(formattedSinkName)
- * .build();
- * ListenableFuture<LogSink> future = configServiceV2Api.getSinkCallable().futureCall(request);
- * // Do something
- * LogSink response = future.get();
- * }
- *
- */
- public final ApiCallable getSinkCallable() {
- return getSinkCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
- * LogSink sink = LogSink.newBuilder().build();
- * LogSink response = configServiceV2Api.createSink(formattedParent, sink);
- * }
- *
- *
- * @param parent The resource in which to create the sink.
- * Example: `"projects/my-project-id"`.
- *
- * The new sink must be provided in the request.
- * @param sink The new sink, which must not have an identifier that already
- * exists.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogSink createSink(String parent, LogSink sink) {
- PARENT_PATH_TEMPLATE.validate(parent, "createSink");
- CreateSinkRequest request =
- CreateSinkRequest.newBuilder().setParent(parent).setSink(sink).build();
- return createSink(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
- * LogSink sink = LogSink.newBuilder().build();
- * CreateSinkRequest request = CreateSinkRequest.newBuilder()
- * .setParent(formattedParent)
- * .setSink(sink)
- * .build();
- * LogSink response = configServiceV2Api.createSink(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogSink createSink(CreateSinkRequest request) {
- return createSinkCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedParent = ConfigServiceV2Api.formatParentName("[PROJECT]");
- * LogSink sink = LogSink.newBuilder().build();
- * CreateSinkRequest request = CreateSinkRequest.newBuilder()
- * .setParent(formattedParent)
- * .setSink(sink)
- * .build();
- * ListenableFuture<LogSink> future = configServiceV2Api.createSinkCallable().futureCall(request);
- * // Do something
- * LogSink response = future.get();
- * }
- *
- */
- public final ApiCallable createSinkCallable() {
- return createSinkCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates or updates a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * LogSink sink = LogSink.newBuilder().build();
- * LogSink response = configServiceV2Api.updateSink(formattedSinkName, sink);
- * }
- *
- *
- * @param sinkName The resource name of the sink to update.
- * Example: `"projects/my-project-id/sinks/my-sink-id"`.
- *
- * The updated sink must be provided in the request and have the
- * same name that is specified in `sinkName`. If the sink does not
- * exist, it is created.
- * @param sink The updated sink, whose name must be the same as the sink
- * identifier in `sinkName`. If `sinkName` does not exist, then
- * this method creates a new sink.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogSink updateSink(String sinkName, LogSink sink) {
- SINK_PATH_TEMPLATE.validate(sinkName, "updateSink");
- UpdateSinkRequest request =
- UpdateSinkRequest.newBuilder().setSinkName(sinkName).setSink(sink).build();
- return updateSink(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates or updates a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * LogSink sink = LogSink.newBuilder().build();
- * UpdateSinkRequest request = UpdateSinkRequest.newBuilder()
- * .setSinkName(formattedSinkName)
- * .setSink(sink)
- * .build();
- * LogSink response = configServiceV2Api.updateSink(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogSink updateSink(UpdateSinkRequest request) {
- return updateSinkCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates or updates a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * LogSink sink = LogSink.newBuilder().build();
- * UpdateSinkRequest request = UpdateSinkRequest.newBuilder()
- * .setSinkName(formattedSinkName)
- * .setSink(sink)
- * .build();
- * ListenableFuture<LogSink> future = configServiceV2Api.updateSinkCallable().futureCall(request);
- * // Do something
- * LogSink response = future.get();
- * }
- *
- */
- public final ApiCallable updateSinkCallable() {
- return updateSinkCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * configServiceV2Api.deleteSink(formattedSinkName);
- * }
- *
- *
- * @param sinkName The resource name of the sink to delete.
- * Example: `"projects/my-project-id/sinks/my-sink-id"`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void deleteSink(String sinkName) {
- SINK_PATH_TEMPLATE.validate(sinkName, "deleteSink");
- DeleteSinkRequest request = DeleteSinkRequest.newBuilder().setSinkName(sinkName).build();
- deleteSink(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * DeleteSinkRequest request = DeleteSinkRequest.newBuilder()
- * .setSinkName(formattedSinkName)
- * .build();
- * configServiceV2Api.deleteSink(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final void deleteSink(DeleteSinkRequest request) {
- deleteSinkCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a sink.
- *
- * Sample code:
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * DeleteSinkRequest request = DeleteSinkRequest.newBuilder()
- * .setSinkName(formattedSinkName)
- * .build();
- * ListenableFuture<Void> future = configServiceV2Api.deleteSinkCallable().futureCall(request);
- * // Do something
- * future.get();
- * }
- *
- */
- public final ApiCallable deleteSinkCallable() {
- return deleteSinkCallable;
- }
-
- /**
- * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
- * cancelled.
- */
- @Override
- public final void close() throws Exception {
- for (AutoCloseable closeable : closeables) {
- closeable.close();
- }
- }
-}
diff --git a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java b/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java
deleted file mode 100644
index 39215faeef26..000000000000
--- a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.logging.spi.v2;
-
-import com.google.api.gax.core.ConnectionSettings;
-import com.google.api.gax.core.RetrySettings;
-import com.google.api.gax.grpc.ApiCallSettings;
-import com.google.api.gax.grpc.PageStreamingCallSettings;
-import com.google.api.gax.grpc.PageStreamingDescriptor;
-import com.google.api.gax.grpc.ServiceApiSettings;
-import com.google.api.gax.grpc.SimpleCallSettings;
-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.logging.v2.ConfigServiceV2Grpc;
-import com.google.logging.v2.CreateSinkRequest;
-import com.google.logging.v2.DeleteSinkRequest;
-import com.google.logging.v2.GetSinkRequest;
-import com.google.logging.v2.ListSinksRequest;
-import com.google.logging.v2.ListSinksResponse;
-import com.google.logging.v2.LogSink;
-import com.google.logging.v2.UpdateSinkRequest;
-import com.google.protobuf.Empty;
-import io.grpc.ManagedChannel;
-import io.grpc.Status;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-import org.joda.time.Duration;
-
-// AUTO-GENERATED DOCUMENTATION AND CLASS
-/**
- * Settings class to configure an instance of {@link ConfigServiceV2Api}.
- *
- * The default instance has everything set to sensible defaults:
- *
- *
- * - The default service address (logging.googleapis.com) and default port (443)
- * 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 getSink to 30 seconds:
- *
- *
- *
- * ConfigServiceV2Settings.Builder configServiceV2SettingsBuilder =
- * ConfigServiceV2Settings.defaultBuilder();
- * configServiceV2SettingsBuilder.getSinkSettings().getRetrySettingsBuilder()
- * .setTotalTimeout(Duration.standardSeconds(30));
- * ConfigServiceV2Settings configServiceV2Settings = configServiceV2SettingsBuilder.build();
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class ConfigServiceV2Settings extends ServiceApiSettings {
- /**
- * The default address of the service.
- */
- private static final String DEFAULT_SERVICE_ADDRESS = "logging.googleapis.com";
-
- /**
- * The default port of the service.
- */
- private static final int DEFAULT_SERVICE_PORT = 443;
-
- /**
- * 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/cloud-platform.read-only")
- .add("https://www.googleapis.com/auth/logging.admin")
- .add("https://www.googleapis.com/auth/logging.read")
- .add("https://www.googleapis.com/auth/logging.write")
- .build();
-
- /**
- * The default connection settings of the service.
- */
- public static final ConnectionSettings DEFAULT_CONNECTION_SETTINGS =
- ConnectionSettings.newBuilder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build();
-
- private final PageStreamingCallSettings
- listSinksSettings;
- private final SimpleCallSettings getSinkSettings;
- private final SimpleCallSettings createSinkSettings;
- private final SimpleCallSettings updateSinkSettings;
- private final SimpleCallSettings deleteSinkSettings;
-
- /**
- * Returns the object with the settings used for calls to listSinks.
- */
- public PageStreamingCallSettings
- listSinksSettings() {
- return listSinksSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to getSink.
- */
- public SimpleCallSettings getSinkSettings() {
- return getSinkSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to createSink.
- */
- public SimpleCallSettings createSinkSettings() {
- return createSinkSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to updateSink.
- */
- public SimpleCallSettings updateSinkSettings() {
- return updateSinkSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to deleteSink.
- */
- public SimpleCallSettings deleteSinkSettings() {
- return deleteSinkSettings;
- }
-
- /**
- * Returns the default service address.
- */
- public static String getDefaultServiceAddress() {
- return DEFAULT_SERVICE_ADDRESS;
- }
-
- /**
- * Returns the default service port.
- */
- public static int getDefaultServicePort() {
- return DEFAULT_SERVICE_PORT;
- }
-
- /**
- * Returns the default service scopes.
- */
- public static ImmutableList getDefaultServiceScopes() {
- return DEFAULT_SERVICE_SCOPES;
- }
-
- /**
- * Returns a builder for this class with recommended defaults.
- */
- public static Builder defaultBuilder() {
- return Builder.createDefault();
- }
-
- /**
- * Returns a new builder for this class.
- */
- public static Builder newBuilder() {
- return new Builder();
- }
-
- /**
- * Returns a builder containing all the values of this settings class.
- */
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- private ConfigServiceV2Settings(Builder settingsBuilder) throws IOException {
- super(
- settingsBuilder.getChannelProvider(),
- settingsBuilder.getExecutorProvider(),
- settingsBuilder.getGeneratorName(),
- settingsBuilder.getGeneratorVersion(),
- settingsBuilder.getClientLibName(),
- settingsBuilder.getClientLibVersion());
-
- listSinksSettings = settingsBuilder.listSinksSettings().build();
- getSinkSettings = settingsBuilder.getSinkSettings().build();
- createSinkSettings = settingsBuilder.createSinkSettings().build();
- updateSinkSettings = settingsBuilder.updateSinkSettings().build();
- deleteSinkSettings = settingsBuilder.deleteSinkSettings().build();
- }
-
- private static PageStreamingDescriptor
- LIST_SINKS_PAGE_STR_DESC =
- new PageStreamingDescriptor() {
- @Override
- public Object emptyToken() {
- return "";
- }
-
- @Override
- public ListSinksRequest injectToken(ListSinksRequest payload, Object token) {
- return ListSinksRequest.newBuilder(payload).setPageToken((String) token).build();
- }
-
- @Override
- public Object extractNextToken(ListSinksResponse payload) {
- return payload.getNextPageToken();
- }
-
- @Override
- public Iterable extractResources(ListSinksResponse payload) {
- return payload.getSinksList();
- }
- };
-
- /**
- * Builder for ConfigServiceV2Settings.
- */
- public static class Builder extends ServiceApiSettings.Builder {
- private final ImmutableList methodSettingsBuilders;
-
- private PageStreamingCallSettings.Builder
- listSinksSettings;
- private SimpleCallSettings.Builder getSinkSettings;
- private SimpleCallSettings.Builder createSinkSettings;
- private SimpleCallSettings.Builder updateSinkSettings;
- private SimpleCallSettings.Builder deleteSinkSettings;
-
- private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS;
-
- static {
- ImmutableMap.Builder> definitions = ImmutableMap.builder();
- definitions.put(
- "idempotent",
- Sets.immutableEnumSet(
- Lists.newArrayList(
- Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE)));
- definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList()));
- RETRYABLE_CODE_DEFINITIONS = definitions.build();
- }
-
- private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
-
- static {
- ImmutableMap.Builder definitions = ImmutableMap.builder();
- RetrySettings.Builder settingsBuilder = null;
- settingsBuilder =
- RetrySettings.newBuilder()
- .setInitialRetryDelay(Duration.millis(100L))
- .setRetryDelayMultiplier(1.2)
- .setMaxRetryDelay(Duration.millis(1000L))
- .setInitialRpcTimeout(Duration.millis(2000L))
- .setRpcTimeoutMultiplier(1.5)
- .setMaxRpcTimeout(Duration.millis(30000L))
- .setTotalTimeout(Duration.millis(45000L));
- definitions.put("default", settingsBuilder);
- RETRY_PARAM_DEFINITIONS = definitions.build();
- }
-
- private Builder() {
- super(DEFAULT_CONNECTION_SETTINGS);
-
- listSinksSettings =
- PageStreamingCallSettings.newBuilder(
- ConfigServiceV2Grpc.METHOD_LIST_SINKS, LIST_SINKS_PAGE_STR_DESC);
-
- getSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_GET_SINK);
-
- createSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_CREATE_SINK);
-
- updateSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_UPDATE_SINK);
-
- deleteSinkSettings = SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_DELETE_SINK);
-
- methodSettingsBuilders =
- ImmutableList.of(
- listSinksSettings,
- getSinkSettings,
- createSinkSettings,
- updateSinkSettings,
- deleteSinkSettings);
- }
-
- private static Builder createDefault() {
- Builder builder = new Builder();
-
- builder
- .listSinksSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .getSinkSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .createSinkSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .updateSinkSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .deleteSinkSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- return builder;
- }
-
- private Builder(ConfigServiceV2Settings settings) {
- super(settings);
-
- listSinksSettings = settings.listSinksSettings.toBuilder();
- getSinkSettings = settings.getSinkSettings.toBuilder();
- createSinkSettings = settings.createSinkSettings.toBuilder();
- updateSinkSettings = settings.updateSinkSettings.toBuilder();
- deleteSinkSettings = settings.deleteSinkSettings.toBuilder();
-
- methodSettingsBuilders =
- ImmutableList.of(
- listSinksSettings,
- getSinkSettings,
- createSinkSettings,
- updateSinkSettings,
- deleteSinkSettings);
- }
-
- @Override
- protected ConnectionSettings getDefaultConnectionSettings() {
- return DEFAULT_CONNECTION_SETTINGS;
- }
-
- @Override
- public Builder provideExecutorWith(ScheduledExecutorService executor, boolean shouldAutoClose) {
- super.provideExecutorWith(executor, shouldAutoClose);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(ManagedChannel channel, boolean shouldAutoClose) {
- super.provideChannelWith(channel, shouldAutoClose);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(ConnectionSettings settings) {
- super.provideChannelWith(settings);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(Credentials credentials) {
- super.provideChannelWith(credentials);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(List scopes) {
- super.provideChannelWith(scopes);
- return this;
- }
-
- @Override
- public Builder setGeneratorHeader(String name, String version) {
- super.setGeneratorHeader(name, version);
- return this;
- }
-
- @Override
- public Builder setClientLibHeader(String name, String version) {
- super.setClientLibHeader(name, version);
- return this;
- }
-
- /**
- * Applies the given settings to all of the API methods in this service. Only
- * values that are non-null will be applied, so this method is not capable
- * of un-setting any values.
- */
- public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception {
- super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings);
- return this;
- }
-
- /**
- * Returns the builder for the settings used for calls to listSinks.
- */
- public PageStreamingCallSettings.Builder
- listSinksSettings() {
- return listSinksSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to getSink.
- */
- public SimpleCallSettings.Builder getSinkSettings() {
- return getSinkSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to createSink.
- */
- public SimpleCallSettings.Builder createSinkSettings() {
- return createSinkSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to updateSink.
- */
- public SimpleCallSettings.Builder updateSinkSettings() {
- return updateSinkSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to deleteSink.
- */
- public SimpleCallSettings.Builder deleteSinkSettings() {
- return deleteSinkSettings;
- }
-
- @Override
- public ConfigServiceV2Settings build() throws IOException {
- return new ConfigServiceV2Settings(this);
- }
- }
-}
diff --git a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java b/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java
deleted file mode 100644
index be62409e99a9..000000000000
--- a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.logging.spi.v2;
-
-import com.google.api.MonitoredResource;
-import com.google.api.MonitoredResourceDescriptor;
-import com.google.api.gax.core.PageAccessor;
-import com.google.api.gax.grpc.ApiCallable;
-import com.google.api.gax.protobuf.PathTemplate;
-import com.google.logging.v2.DeleteLogRequest;
-import com.google.logging.v2.ListLogEntriesRequest;
-import com.google.logging.v2.ListLogEntriesResponse;
-import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest;
-import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
-import com.google.logging.v2.LogEntry;
-import com.google.logging.v2.WriteLogEntriesRequest;
-import com.google.logging.v2.WriteLogEntriesResponse;
-import com.google.protobuf.Empty;
-import io.grpc.ManagedChannel;
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ScheduledExecutorService;
-
-// AUTO-GENERATED DOCUMENTATION AND SERVICE
-/**
- * Service Description: Service for ingesting and querying logs.
- *
- * 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 (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
- * loggingServiceV2Api.deleteLog(formattedLogName);
- * }
- *
- *
- *
- * Note: close() needs to be called on the loggingServiceV2Api 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:
- *
- *
- * - 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.
- *
- 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.
- *
- A "callable" method. This type of method takes no parameters and returns an immutable
- * ApiCallable 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 LoggingServiceV2Settings to
- * create(). For example:
- *
- *
- *
- * LoggingServiceV2Settings loggingServiceV2Settings = LoggingServiceV2Settings.defaultBuilder()
- * .provideChannelWith(myCredentials)
- * .build();
- * LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create(loggingServiceV2Settings);
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class LoggingServiceV2Api implements AutoCloseable {
- private final LoggingServiceV2Settings settings;
- private final ManagedChannel channel;
- private final ScheduledExecutorService executor;
- private final List closeables = new ArrayList<>();
-
- private final ApiCallable deleteLogCallable;
- private final ApiCallable
- writeLogEntriesCallable;
- private final ApiCallable listLogEntriesCallable;
- private final ApiCallable>
- listLogEntriesPagedCallable;
- private final ApiCallable<
- ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>
- listMonitoredResourceDescriptorsCallable;
- private final ApiCallable<
- ListMonitoredResourceDescriptorsRequest, PageAccessor>
- listMonitoredResourceDescriptorsPagedCallable;
-
- public final LoggingServiceV2Settings getSettings() {
- return settings;
- }
-
- private static final PathTemplate PARENT_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}");
-
- private static final PathTemplate LOG_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/logs/{log}");
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a parent resource.
- */
- public static final String formatParentName(String project) {
- return PARENT_PATH_TEMPLATE.instantiate("project", project);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a log resource.
- */
- public static final String formatLogName(String project, String log) {
- return LOG_PATH_TEMPLATE.instantiate(
- "project", project,
- "log", log);
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a parent resource.
- */
- public static final String parseProjectFromParentName(String parentName) {
- return PARENT_PATH_TEMPLATE.parse(parentName).get("project");
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a log resource.
- */
- public static final String parseProjectFromLogName(String logName) {
- return LOG_PATH_TEMPLATE.parse(logName).get("project");
- }
-
- /**
- * Parses the log from the given fully-qualified path which
- * represents a log resource.
- */
- public static final String parseLogFromLogName(String logName) {
- return LOG_PATH_TEMPLATE.parse(logName).get("log");
- }
-
- /**
- * Constructs an instance of LoggingServiceV2Api with default settings.
- */
- public static final LoggingServiceV2Api create() throws IOException {
- return create(LoggingServiceV2Settings.defaultBuilder().build());
- }
-
- /**
- * Constructs an instance of LoggingServiceV2Api, 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 LoggingServiceV2Api create(LoggingServiceV2Settings settings)
- throws IOException {
- return new LoggingServiceV2Api(settings);
- }
-
- /**
- * Constructs an instance of LoggingServiceV2Api, using the given settings.
- * This is protected so that it easy to make a subclass, but otherwise, the static
- * factory methods should be preferred.
- */
- protected LoggingServiceV2Api(LoggingServiceV2Settings settings) throws IOException {
- this.settings = settings;
- this.executor = settings.getExecutorProvider().getOrBuildExecutor();
- this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
-
- this.deleteLogCallable =
- ApiCallable.create(settings.deleteLogSettings(), this.channel, this.executor);
- this.writeLogEntriesCallable =
- ApiCallable.create(settings.writeLogEntriesSettings(), this.channel, this.executor);
- this.listLogEntriesCallable =
- ApiCallable.create(settings.listLogEntriesSettings(), this.channel, this.executor);
- this.listLogEntriesPagedCallable =
- ApiCallable.createPagedVariant(
- settings.listLogEntriesSettings(), this.channel, this.executor);
- this.listMonitoredResourceDescriptorsCallable =
- ApiCallable.create(
- settings.listMonitoredResourceDescriptorsSettings(), this.channel, this.executor);
- this.listMonitoredResourceDescriptorsPagedCallable =
- ApiCallable.createPagedVariant(
- settings.listMonitoredResourceDescriptorsSettings(), this.channel, this.executor);
-
- if (settings.getChannelProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- channel.shutdown();
- }
- });
- }
- if (settings.getExecutorProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- executor.shutdown();
- }
- });
- }
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a log and all its log entries.
- * The log will reappear if it receives new entries.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
- * loggingServiceV2Api.deleteLog(formattedLogName);
- * }
- *
- *
- * @param logName Required. The resource name of the log to delete. Example:
- * `"projects/my-project/logs/syslog"`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void deleteLog(String logName) {
- LOG_PATH_TEMPLATE.validate(logName, "deleteLog");
- DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(logName).build();
- deleteLog(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a log and all its log entries.
- * The log will reappear if it receives new entries.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
- * DeleteLogRequest request = DeleteLogRequest.newBuilder()
- * .setLogName(formattedLogName)
- * .build();
- * loggingServiceV2Api.deleteLog(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final void deleteLog(DeleteLogRequest request) {
- deleteLogCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a log and all its log entries.
- * The log will reappear if it receives new entries.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
- * DeleteLogRequest request = DeleteLogRequest.newBuilder()
- * .setLogName(formattedLogName)
- * .build();
- * ListenableFuture<Void> future = loggingServiceV2Api.deleteLogCallable().futureCall(request);
- * // Do something
- * future.get();
- * }
- *
- */
- public final ApiCallable deleteLogCallable() {
- return deleteLogCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Writes log entries to Stackdriver Logging. All log entries are
- * written by this method.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * String logName = "";
- * MonitoredResource resource = MonitoredResource.newBuilder().build();
- * Map<String, String> labels = new HashMap<>();
- * List<LogEntry> entries = new ArrayList<>();
- * WriteLogEntriesResponse response = loggingServiceV2Api.writeLogEntries(logName, resource, labels, entries);
- * }
- *
- *
- * @param logName Optional. A default log resource name for those log entries in `entries`
- * that do not specify their own `logName`. Example:
- * `"projects/my-project/logs/syslog"`. See
- * [LogEntry][google.logging.v2.LogEntry].
- * @param resource Optional. A default monitored resource for those log entries in `entries`
- * that do not specify their own `resource`.
- * @param labels Optional. User-defined `key:value` items that are added to
- * the `labels` field of each log entry in `entries`, except when a log
- * entry specifies its own `key:value` item with the same key.
- * Example: `{ "size": "large", "color":"red" }`
- * @param entries Required. The log entries to write. The log entries must have values for
- * all required fields.
- *
- * To improve throughput and to avoid exceeding the quota limit for calls
- * to `entries.write`, use this field to write multiple log entries at once
- * rather than // calling this method for each log entry.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final WriteLogEntriesResponse writeLogEntries(
- String logName,
- MonitoredResource resource,
- Map labels,
- List entries) {
- LOG_PATH_TEMPLATE.validate(logName, "writeLogEntries");
- WriteLogEntriesRequest request =
- WriteLogEntriesRequest.newBuilder()
- .setLogName(logName)
- .setResource(resource)
- .putAllLabels(labels)
- .addAllEntries(entries)
- .build();
- return writeLogEntries(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Writes log entries to Stackdriver Logging. All log entries are
- * written by this method.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * List<LogEntry> entries = new ArrayList<>();
- * WriteLogEntriesRequest request = WriteLogEntriesRequest.newBuilder()
- * .addAllEntries(entries)
- * .build();
- * WriteLogEntriesResponse response = loggingServiceV2Api.writeLogEntries(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest request) {
- return writeLogEntriesCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Writes log entries to Stackdriver Logging. All log entries are
- * written by this method.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * List<LogEntry> entries = new ArrayList<>();
- * WriteLogEntriesRequest request = WriteLogEntriesRequest.newBuilder()
- * .addAllEntries(entries)
- * .build();
- * ListenableFuture<WriteLogEntriesResponse> future = loggingServiceV2Api.writeLogEntriesCallable().futureCall(request);
- * // Do something
- * WriteLogEntriesResponse response = future.get();
- * }
- *
- */
- public final ApiCallable
- writeLogEntriesCallable() {
- return writeLogEntriesCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists log entries. Use this method to retrieve log entries from Cloud
- * Logging. For ways to export log entries, see
- * [Exporting Logs](/logging/docs/export).
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * List<String> projectIds = new ArrayList<>();
- * String filter = "";
- * String orderBy = "";
- * for (LogEntry element : loggingServiceV2Api.listLogEntries(projectIds, filter, orderBy)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param projectIds Required. One or more project IDs or project numbers from which to retrieve
- * log entries. Examples of a project ID: `"my-project-1A"`, `"1234567890"`.
- * @param filter Optional. An [advanced logs filter](/logging/docs/view/advanced_filters).
- * The filter is compared against all log entries in the projects specified by
- * `projectIds`. Only entries that match the filter are retrieved. An empty
- * filter matches all log entries.
- * @param orderBy Optional. How the results should be sorted. Presently, the only permitted
- * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first
- * option returns entries in order of increasing values of
- * `LogEntry.timestamp` (oldest first), and the second option returns entries
- * in order of decreasing timestamps (newest first). Entries with equal
- * timestamps are returned in order of `LogEntry.insertId`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listLogEntries(
- List projectIds, String filter, String orderBy) {
- ListLogEntriesRequest request =
- ListLogEntriesRequest.newBuilder()
- .addAllProjectIds(projectIds)
- .setFilter(filter)
- .setOrderBy(orderBy)
- .build();
- return listLogEntries(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists log entries. Use this method to retrieve log entries from Cloud
- * Logging. For ways to export log entries, see
- * [Exporting Logs](/logging/docs/export).
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * List<String> projectIds = new ArrayList<>();
- * ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder()
- * .addAllProjectIds(projectIds)
- * .build();
- * for (LogEntry element : loggingServiceV2Api.listLogEntries(request)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listLogEntries(ListLogEntriesRequest request) {
- return listLogEntriesPagedCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists log entries. Use this method to retrieve log entries from Cloud
- * Logging. For ways to export log entries, see
- * [Exporting Logs](/logging/docs/export).
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * List<String> projectIds = new ArrayList<>();
- * ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder()
- * .addAllProjectIds(projectIds)
- * .build();
- * ListenableFuture<PageAccessor<LogEntry>> future = loggingServiceV2Api.listLogEntriesPagedCallable().futureCall(request);
- * // Do something
- * for (LogEntry element : future.get()) {
- * // doThingsWith(element);
- * }
- * }
- *
- */
- public final ApiCallable>
- listLogEntriesPagedCallable() {
- return listLogEntriesPagedCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists log entries. Use this method to retrieve log entries from Cloud
- * Logging. For ways to export log entries, see
- * [Exporting Logs](/logging/docs/export).
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * List<String> projectIds = new ArrayList<>();
- * ListLogEntriesRequest request = ListLogEntriesRequest.newBuilder()
- * .addAllProjectIds(projectIds)
- * .build();
- * while (true) {
- * ListLogEntriesResponse response = loggingServiceV2Api.listLogEntriesCallable().call(request);
- * for (LogEntry element : response.getEntriesList()) {
- * // doThingsWith(element);
- * }
- * String nextPageToken = response.getNextPageToken();
- * if (!Strings.isNullOrEmpty(nextPageToken)) {
- * request = request.toBuilder().setPageToken(nextPageToken).build();
- * } else {
- * break;
- * }
- * }
- * }
- *
- */
- public final ApiCallable listLogEntriesCallable() {
- return listLogEntriesCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists the monitored resource descriptors used by Stackdriver Logging.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
- * .build();
- * for (MonitoredResourceDescriptor element : loggingServiceV2Api.listMonitoredResourceDescriptors(request)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listMonitoredResourceDescriptors(
- ListMonitoredResourceDescriptorsRequest request) {
- return listMonitoredResourceDescriptorsPagedCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists the monitored resource descriptors used by Stackdriver Logging.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
- * .build();
- * ListenableFuture<PageAccessor<MonitoredResourceDescriptor>> future = loggingServiceV2Api.listMonitoredResourceDescriptorsPagedCallable().futureCall(request);
- * // Do something
- * for (MonitoredResourceDescriptor element : future.get()) {
- * // doThingsWith(element);
- * }
- * }
- *
- */
- public final ApiCallable<
- ListMonitoredResourceDescriptorsRequest, PageAccessor>
- listMonitoredResourceDescriptorsPagedCallable() {
- return listMonitoredResourceDescriptorsPagedCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists the monitored resource descriptors used by Stackdriver Logging.
- *
- * Sample code:
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * ListMonitoredResourceDescriptorsRequest request = ListMonitoredResourceDescriptorsRequest.newBuilder()
- * .build();
- * while (true) {
- * ListMonitoredResourceDescriptorsResponse response = loggingServiceV2Api.listMonitoredResourceDescriptorsCallable().call(request);
- * for (MonitoredResourceDescriptor element : response.getResourceDescriptorsList()) {
- * // doThingsWith(element);
- * }
- * String nextPageToken = response.getNextPageToken();
- * if (!Strings.isNullOrEmpty(nextPageToken)) {
- * request = request.toBuilder().setPageToken(nextPageToken).build();
- * } else {
- * break;
- * }
- * }
- * }
- *
- */
- public final ApiCallable<
- ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>
- listMonitoredResourceDescriptorsCallable() {
- return listMonitoredResourceDescriptorsCallable;
- }
-
- /**
- * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
- * cancelled.
- */
- @Override
- public final void close() throws Exception {
- for (AutoCloseable closeable : closeables) {
- closeable.close();
- }
- }
-}
diff --git a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java b/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java
deleted file mode 100644
index 0e0f4da5e345..000000000000
--- a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.logging.spi.v2;
-
-import com.google.api.MonitoredResourceDescriptor;
-import com.google.api.gax.core.ConnectionSettings;
-import com.google.api.gax.core.RetrySettings;
-import com.google.api.gax.grpc.ApiCallSettings;
-import com.google.api.gax.grpc.PageStreamingCallSettings;
-import com.google.api.gax.grpc.PageStreamingDescriptor;
-import com.google.api.gax.grpc.ServiceApiSettings;
-import com.google.api.gax.grpc.SimpleCallSettings;
-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.logging.v2.DeleteLogRequest;
-import com.google.logging.v2.ListLogEntriesRequest;
-import com.google.logging.v2.ListLogEntriesResponse;
-import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest;
-import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
-import com.google.logging.v2.LogEntry;
-import com.google.logging.v2.LoggingServiceV2Grpc;
-import com.google.logging.v2.WriteLogEntriesRequest;
-import com.google.logging.v2.WriteLogEntriesResponse;
-import com.google.protobuf.Empty;
-import io.grpc.ManagedChannel;
-import io.grpc.Status;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-import org.joda.time.Duration;
-
-// AUTO-GENERATED DOCUMENTATION AND CLASS
-/**
- * Settings class to configure an instance of {@link LoggingServiceV2Api}.
- *
- * The default instance has everything set to sensible defaults:
- *
- *
- * - The default service address (logging.googleapis.com) and default port (443)
- * 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 deleteLog to 30 seconds:
- *
- *
- *
- * LoggingServiceV2Settings.Builder loggingServiceV2SettingsBuilder =
- * LoggingServiceV2Settings.defaultBuilder();
- * loggingServiceV2SettingsBuilder.deleteLogSettings().getRetrySettingsBuilder()
- * .setTotalTimeout(Duration.standardSeconds(30));
- * LoggingServiceV2Settings loggingServiceV2Settings = loggingServiceV2SettingsBuilder.build();
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class LoggingServiceV2Settings extends ServiceApiSettings {
- /**
- * The default address of the service.
- */
- private static final String DEFAULT_SERVICE_ADDRESS = "logging.googleapis.com";
-
- /**
- * The default port of the service.
- */
- private static final int DEFAULT_SERVICE_PORT = 443;
-
- /**
- * 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/cloud-platform.read-only")
- .add("https://www.googleapis.com/auth/logging.admin")
- .add("https://www.googleapis.com/auth/logging.read")
- .add("https://www.googleapis.com/auth/logging.write")
- .build();
-
- /**
- * The default connection settings of the service.
- */
- public static final ConnectionSettings DEFAULT_CONNECTION_SETTINGS =
- ConnectionSettings.newBuilder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build();
-
- private final SimpleCallSettings deleteLogSettings;
- private final SimpleCallSettings
- writeLogEntriesSettings;
- private final PageStreamingCallSettings
- listLogEntriesSettings;
- private final PageStreamingCallSettings<
- ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
- MonitoredResourceDescriptor>
- listMonitoredResourceDescriptorsSettings;
-
- /**
- * Returns the object with the settings used for calls to deleteLog.
- */
- public SimpleCallSettings deleteLogSettings() {
- return deleteLogSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to writeLogEntries.
- */
- public SimpleCallSettings
- writeLogEntriesSettings() {
- return writeLogEntriesSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to listLogEntries.
- */
- public PageStreamingCallSettings
- listLogEntriesSettings() {
- return listLogEntriesSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to listMonitoredResourceDescriptors.
- */
- public PageStreamingCallSettings<
- ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
- MonitoredResourceDescriptor>
- listMonitoredResourceDescriptorsSettings() {
- return listMonitoredResourceDescriptorsSettings;
- }
-
- /**
- * Returns the default service address.
- */
- public static String getDefaultServiceAddress() {
- return DEFAULT_SERVICE_ADDRESS;
- }
-
- /**
- * Returns the default service port.
- */
- public static int getDefaultServicePort() {
- return DEFAULT_SERVICE_PORT;
- }
-
- /**
- * Returns the default service scopes.
- */
- public static ImmutableList getDefaultServiceScopes() {
- return DEFAULT_SERVICE_SCOPES;
- }
-
- /**
- * Returns a builder for this class with recommended defaults.
- */
- public static Builder defaultBuilder() {
- return Builder.createDefault();
- }
-
- /**
- * Returns a new builder for this class.
- */
- public static Builder newBuilder() {
- return new Builder();
- }
-
- /**
- * Returns a builder containing all the values of this settings class.
- */
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- private LoggingServiceV2Settings(Builder settingsBuilder) throws IOException {
- super(
- settingsBuilder.getChannelProvider(),
- settingsBuilder.getExecutorProvider(),
- settingsBuilder.getGeneratorName(),
- settingsBuilder.getGeneratorVersion(),
- settingsBuilder.getClientLibName(),
- settingsBuilder.getClientLibVersion());
-
- deleteLogSettings = settingsBuilder.deleteLogSettings().build();
- writeLogEntriesSettings = settingsBuilder.writeLogEntriesSettings().build();
- listLogEntriesSettings = settingsBuilder.listLogEntriesSettings().build();
- listMonitoredResourceDescriptorsSettings =
- settingsBuilder.listMonitoredResourceDescriptorsSettings().build();
- }
-
- private static PageStreamingDescriptor
- LIST_LOG_ENTRIES_PAGE_STR_DESC =
- new PageStreamingDescriptor() {
- @Override
- public Object emptyToken() {
- return "";
- }
-
- @Override
- public ListLogEntriesRequest injectToken(ListLogEntriesRequest payload, Object token) {
- return ListLogEntriesRequest.newBuilder(payload).setPageToken((String) token).build();
- }
-
- @Override
- public Object extractNextToken(ListLogEntriesResponse payload) {
- return payload.getNextPageToken();
- }
-
- @Override
- public Iterable extractResources(ListLogEntriesResponse payload) {
- return payload.getEntriesList();
- }
- };
-
- private static PageStreamingDescriptor<
- ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
- MonitoredResourceDescriptor>
- LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC =
- new PageStreamingDescriptor<
- ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
- MonitoredResourceDescriptor>() {
- @Override
- public Object emptyToken() {
- return "";
- }
-
- @Override
- public ListMonitoredResourceDescriptorsRequest injectToken(
- ListMonitoredResourceDescriptorsRequest payload, Object token) {
- return ListMonitoredResourceDescriptorsRequest.newBuilder(payload)
- .setPageToken((String) token)
- .build();
- }
-
- @Override
- public Object extractNextToken(ListMonitoredResourceDescriptorsResponse payload) {
- return payload.getNextPageToken();
- }
-
- @Override
- public Iterable extractResources(
- ListMonitoredResourceDescriptorsResponse payload) {
- return payload.getResourceDescriptorsList();
- }
- };
-
- /**
- * Builder for LoggingServiceV2Settings.
- */
- public static class Builder extends ServiceApiSettings.Builder {
- private final ImmutableList methodSettingsBuilders;
-
- private SimpleCallSettings.Builder deleteLogSettings;
- private SimpleCallSettings.Builder
- writeLogEntriesSettings;
- private PageStreamingCallSettings.Builder<
- ListLogEntriesRequest, ListLogEntriesResponse, LogEntry>
- listLogEntriesSettings;
- private PageStreamingCallSettings.Builder<
- ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
- MonitoredResourceDescriptor>
- listMonitoredResourceDescriptorsSettings;
-
- private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS;
-
- static {
- ImmutableMap.Builder> definitions = ImmutableMap.builder();
- definitions.put(
- "idempotent",
- Sets.immutableEnumSet(
- Lists.newArrayList(
- Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE)));
- definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList()));
- RETRYABLE_CODE_DEFINITIONS = definitions.build();
- }
-
- private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
-
- static {
- ImmutableMap.Builder definitions = ImmutableMap.builder();
- RetrySettings.Builder settingsBuilder = null;
- settingsBuilder =
- RetrySettings.newBuilder()
- .setInitialRetryDelay(Duration.millis(100L))
- .setRetryDelayMultiplier(1.2)
- .setMaxRetryDelay(Duration.millis(1000L))
- .setInitialRpcTimeout(Duration.millis(2000L))
- .setRpcTimeoutMultiplier(1.5)
- .setMaxRpcTimeout(Duration.millis(30000L))
- .setTotalTimeout(Duration.millis(45000L));
- definitions.put("default", settingsBuilder);
- settingsBuilder =
- RetrySettings.newBuilder()
- .setInitialRetryDelay(Duration.millis(100L))
- .setRetryDelayMultiplier(1.2)
- .setMaxRetryDelay(Duration.millis(1000L))
- .setInitialRpcTimeout(Duration.millis(7000L))
- .setRpcTimeoutMultiplier(1.5)
- .setMaxRpcTimeout(Duration.millis(30000L))
- .setTotalTimeout(Duration.millis(45000L));
- definitions.put("list", settingsBuilder);
- RETRY_PARAM_DEFINITIONS = definitions.build();
- }
-
- private Builder() {
- super(DEFAULT_CONNECTION_SETTINGS);
-
- deleteLogSettings = SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_DELETE_LOG);
-
- writeLogEntriesSettings =
- SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_WRITE_LOG_ENTRIES);
-
- listLogEntriesSettings =
- PageStreamingCallSettings.newBuilder(
- LoggingServiceV2Grpc.METHOD_LIST_LOG_ENTRIES, LIST_LOG_ENTRIES_PAGE_STR_DESC);
-
- listMonitoredResourceDescriptorsSettings =
- PageStreamingCallSettings.newBuilder(
- LoggingServiceV2Grpc.METHOD_LIST_MONITORED_RESOURCE_DESCRIPTORS,
- LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC);
-
- methodSettingsBuilders =
- ImmutableList.of(
- deleteLogSettings,
- writeLogEntriesSettings,
- listLogEntriesSettings,
- listMonitoredResourceDescriptorsSettings);
- }
-
- private static Builder createDefault() {
- Builder builder = new Builder();
-
- builder
- .deleteLogSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .writeLogEntriesSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .listLogEntriesSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("list"));
-
- builder
- .listMonitoredResourceDescriptorsSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- return builder;
- }
-
- private Builder(LoggingServiceV2Settings settings) {
- super(settings);
-
- deleteLogSettings = settings.deleteLogSettings.toBuilder();
- writeLogEntriesSettings = settings.writeLogEntriesSettings.toBuilder();
- listLogEntriesSettings = settings.listLogEntriesSettings.toBuilder();
- listMonitoredResourceDescriptorsSettings =
- settings.listMonitoredResourceDescriptorsSettings.toBuilder();
-
- methodSettingsBuilders =
- ImmutableList.of(
- deleteLogSettings,
- writeLogEntriesSettings,
- listLogEntriesSettings,
- listMonitoredResourceDescriptorsSettings);
- }
-
- @Override
- protected ConnectionSettings getDefaultConnectionSettings() {
- return DEFAULT_CONNECTION_SETTINGS;
- }
-
- @Override
- public Builder provideExecutorWith(ScheduledExecutorService executor, boolean shouldAutoClose) {
- super.provideExecutorWith(executor, shouldAutoClose);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(ManagedChannel channel, boolean shouldAutoClose) {
- super.provideChannelWith(channel, shouldAutoClose);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(ConnectionSettings settings) {
- super.provideChannelWith(settings);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(Credentials credentials) {
- super.provideChannelWith(credentials);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(List scopes) {
- super.provideChannelWith(scopes);
- return this;
- }
-
- @Override
- public Builder setGeneratorHeader(String name, String version) {
- super.setGeneratorHeader(name, version);
- return this;
- }
-
- @Override
- public Builder setClientLibHeader(String name, String version) {
- super.setClientLibHeader(name, version);
- return this;
- }
-
- /**
- * Applies the given settings to all of the API methods in this service. Only
- * values that are non-null will be applied, so this method is not capable
- * of un-setting any values.
- */
- public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception {
- super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings);
- return this;
- }
-
- /**
- * Returns the builder for the settings used for calls to deleteLog.
- */
- public SimpleCallSettings.Builder deleteLogSettings() {
- return deleteLogSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to writeLogEntries.
- */
- public SimpleCallSettings.Builder
- writeLogEntriesSettings() {
- return writeLogEntriesSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to listLogEntries.
- */
- public PageStreamingCallSettings.Builder<
- ListLogEntriesRequest, ListLogEntriesResponse, LogEntry>
- listLogEntriesSettings() {
- return listLogEntriesSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to listMonitoredResourceDescriptors.
- */
- public PageStreamingCallSettings.Builder<
- ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse,
- MonitoredResourceDescriptor>
- listMonitoredResourceDescriptorsSettings() {
- return listMonitoredResourceDescriptorsSettings;
- }
-
- @Override
- public LoggingServiceV2Settings build() throws IOException {
- return new LoggingServiceV2Settings(this);
- }
- }
-}
diff --git a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java b/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java
deleted file mode 100644
index 8d76a2579dba..000000000000
--- a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.logging.spi.v2;
-
-import com.google.api.gax.core.PageAccessor;
-import com.google.api.gax.grpc.ApiCallable;
-import com.google.api.gax.protobuf.PathTemplate;
-import com.google.logging.v2.CreateLogMetricRequest;
-import com.google.logging.v2.DeleteLogMetricRequest;
-import com.google.logging.v2.GetLogMetricRequest;
-import com.google.logging.v2.ListLogMetricsRequest;
-import com.google.logging.v2.ListLogMetricsResponse;
-import com.google.logging.v2.LogMetric;
-import com.google.logging.v2.UpdateLogMetricRequest;
-import com.google.protobuf.Empty;
-import io.grpc.ManagedChannel;
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-
-// AUTO-GENERATED DOCUMENTATION AND SERVICE
-/**
- * Service Description: Service for configuring logs-based metrics.
- *
- * 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 (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * LogMetric response = metricsServiceV2Api.getLogMetric(formattedMetricName);
- * }
- *
- *
- *
- * Note: close() needs to be called on the metricsServiceV2Api 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:
- *
- *
- * - 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.
- *
- 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.
- *
- A "callable" method. This type of method takes no parameters and returns an immutable
- * ApiCallable 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 MetricsServiceV2Settings to
- * create(). For example:
- *
- *
- *
- * MetricsServiceV2Settings metricsServiceV2Settings = MetricsServiceV2Settings.defaultBuilder()
- * .provideChannelWith(myCredentials)
- * .build();
- * MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create(metricsServiceV2Settings);
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class MetricsServiceV2Api implements AutoCloseable {
- private final MetricsServiceV2Settings settings;
- private final ManagedChannel channel;
- private final ScheduledExecutorService executor;
- private final List closeables = new ArrayList<>();
-
- private final ApiCallable listLogMetricsCallable;
- private final ApiCallable>
- listLogMetricsPagedCallable;
- private final ApiCallable getLogMetricCallable;
- private final ApiCallable createLogMetricCallable;
- private final ApiCallable updateLogMetricCallable;
- private final ApiCallable deleteLogMetricCallable;
-
- public final MetricsServiceV2Settings getSettings() {
- return settings;
- }
-
- private static final PathTemplate PARENT_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}");
-
- private static final PathTemplate METRIC_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/metrics/{metric}");
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a parent resource.
- */
- public static final String formatParentName(String project) {
- return PARENT_PATH_TEMPLATE.instantiate("project", project);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a metric resource.
- */
- public static final String formatMetricName(String project, String metric) {
- return METRIC_PATH_TEMPLATE.instantiate(
- "project", project,
- "metric", metric);
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a parent resource.
- */
- public static final String parseProjectFromParentName(String parentName) {
- return PARENT_PATH_TEMPLATE.parse(parentName).get("project");
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a metric resource.
- */
- public static final String parseProjectFromMetricName(String metricName) {
- return METRIC_PATH_TEMPLATE.parse(metricName).get("project");
- }
-
- /**
- * Parses the metric from the given fully-qualified path which
- * represents a metric resource.
- */
- public static final String parseMetricFromMetricName(String metricName) {
- return METRIC_PATH_TEMPLATE.parse(metricName).get("metric");
- }
-
- /**
- * Constructs an instance of MetricsServiceV2Api with default settings.
- */
- public static final MetricsServiceV2Api create() throws IOException {
- return create(MetricsServiceV2Settings.defaultBuilder().build());
- }
-
- /**
- * Constructs an instance of MetricsServiceV2Api, 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 MetricsServiceV2Api create(MetricsServiceV2Settings settings)
- throws IOException {
- return new MetricsServiceV2Api(settings);
- }
-
- /**
- * Constructs an instance of MetricsServiceV2Api, using the given settings.
- * This is protected so that it easy to make a subclass, but otherwise, the static
- * factory methods should be preferred.
- */
- protected MetricsServiceV2Api(MetricsServiceV2Settings settings) throws IOException {
- this.settings = settings;
- this.executor = settings.getExecutorProvider().getOrBuildExecutor();
- this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
-
- this.listLogMetricsCallable =
- ApiCallable.create(settings.listLogMetricsSettings(), this.channel, this.executor);
- this.listLogMetricsPagedCallable =
- ApiCallable.createPagedVariant(
- settings.listLogMetricsSettings(), this.channel, this.executor);
- this.getLogMetricCallable =
- ApiCallable.create(settings.getLogMetricSettings(), this.channel, this.executor);
- this.createLogMetricCallable =
- ApiCallable.create(settings.createLogMetricSettings(), this.channel, this.executor);
- this.updateLogMetricCallable =
- ApiCallable.create(settings.updateLogMetricSettings(), this.channel, this.executor);
- this.deleteLogMetricCallable =
- ApiCallable.create(settings.deleteLogMetricSettings(), this.channel, this.executor);
-
- if (settings.getChannelProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- channel.shutdown();
- }
- });
- }
- if (settings.getExecutorProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- executor.shutdown();
- }
- });
- }
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists logs-based metrics.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
- * for (LogMetric element : metricsServiceV2Api.listLogMetrics(formattedParent)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param parent Required. The resource name containing the metrics.
- * Example: `"projects/my-project-id"`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listLogMetrics(String parent) {
- PARENT_PATH_TEMPLATE.validate(parent, "listLogMetrics");
- ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder().setParent(parent).build();
- return listLogMetrics(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists logs-based metrics.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
- * ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder()
- * .setParent(formattedParent)
- * .build();
- * for (LogMetric element : metricsServiceV2Api.listLogMetrics(request)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listLogMetrics(ListLogMetricsRequest request) {
- return listLogMetricsPagedCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists logs-based metrics.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
- * ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder()
- * .setParent(formattedParent)
- * .build();
- * ListenableFuture<PageAccessor<LogMetric>> future = metricsServiceV2Api.listLogMetricsPagedCallable().futureCall(request);
- * // Do something
- * for (LogMetric element : future.get()) {
- * // doThingsWith(element);
- * }
- * }
- *
- */
- public final ApiCallable>
- listLogMetricsPagedCallable() {
- return listLogMetricsPagedCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists logs-based metrics.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
- * ListLogMetricsRequest request = ListLogMetricsRequest.newBuilder()
- * .setParent(formattedParent)
- * .build();
- * while (true) {
- * ListLogMetricsResponse response = metricsServiceV2Api.listLogMetricsCallable().call(request);
- * for (LogMetric element : response.getMetricsList()) {
- * // doThingsWith(element);
- * }
- * String nextPageToken = response.getNextPageToken();
- * if (!Strings.isNullOrEmpty(nextPageToken)) {
- * request = request.toBuilder().setPageToken(nextPageToken).build();
- * } else {
- * break;
- * }
- * }
- * }
- *
- */
- public final ApiCallable listLogMetricsCallable() {
- return listLogMetricsCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * LogMetric response = metricsServiceV2Api.getLogMetric(formattedMetricName);
- * }
- *
- *
- * @param metricName The resource name of the desired metric.
- * Example: `"projects/my-project-id/metrics/my-metric-id"`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogMetric getLogMetric(String metricName) {
- METRIC_PATH_TEMPLATE.validate(metricName, "getLogMetric");
- GetLogMetricRequest request =
- GetLogMetricRequest.newBuilder().setMetricName(metricName).build();
- return getLogMetric(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * GetLogMetricRequest request = GetLogMetricRequest.newBuilder()
- * .setMetricName(formattedMetricName)
- * .build();
- * LogMetric response = metricsServiceV2Api.getLogMetric(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final LogMetric getLogMetric(GetLogMetricRequest request) {
- return getLogMetricCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * GetLogMetricRequest request = GetLogMetricRequest.newBuilder()
- * .setMetricName(formattedMetricName)
- * .build();
- * ListenableFuture<LogMetric> future = metricsServiceV2Api.getLogMetricCallable().futureCall(request);
- * // Do something
- * LogMetric response = future.get();
- * }
- *
- */
- public final ApiCallable getLogMetricCallable() {
- return getLogMetricCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
- * LogMetric metric = LogMetric.newBuilder().build();
- * LogMetric response = metricsServiceV2Api.createLogMetric(formattedParent, metric);
- * }
- *
- *
- * @param parent The resource name of the project in which to create the metric.
- * Example: `"projects/my-project-id"`.
- *
- * The new metric must be provided in the request.
- * @param metric The new logs-based metric, which must not have an identifier that
- * already exists.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogMetric createLogMetric(String parent, LogMetric metric) {
- PARENT_PATH_TEMPLATE.validate(parent, "createLogMetric");
- CreateLogMetricRequest request =
- CreateLogMetricRequest.newBuilder().setParent(parent).setMetric(metric).build();
- return createLogMetric(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
- * LogMetric metric = LogMetric.newBuilder().build();
- * CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder()
- * .setParent(formattedParent)
- * .setMetric(metric)
- * .build();
- * LogMetric response = metricsServiceV2Api.createLogMetric(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogMetric createLogMetric(CreateLogMetricRequest request) {
- return createLogMetricCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedParent = MetricsServiceV2Api.formatParentName("[PROJECT]");
- * LogMetric metric = LogMetric.newBuilder().build();
- * CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder()
- * .setParent(formattedParent)
- * .setMetric(metric)
- * .build();
- * ListenableFuture<LogMetric> future = metricsServiceV2Api.createLogMetricCallable().futureCall(request);
- * // Do something
- * LogMetric response = future.get();
- * }
- *
- */
- public final ApiCallable createLogMetricCallable() {
- return createLogMetricCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates or updates a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * LogMetric metric = LogMetric.newBuilder().build();
- * LogMetric response = metricsServiceV2Api.updateLogMetric(formattedMetricName, metric);
- * }
- *
- *
- * @param metricName The resource name of the metric to update.
- * Example: `"projects/my-project-id/metrics/my-metric-id"`.
- *
- * The updated metric must be provided in the request and have the
- * same identifier that is specified in `metricName`.
- * If the metric does not exist, it is created.
- * @param metric The updated metric, whose name must be the same as the
- * metric identifier in `metricName`. If `metricName` does not
- * exist, then a new metric is created.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogMetric updateLogMetric(String metricName, LogMetric metric) {
- METRIC_PATH_TEMPLATE.validate(metricName, "updateLogMetric");
- UpdateLogMetricRequest request =
- UpdateLogMetricRequest.newBuilder().setMetricName(metricName).setMetric(metric).build();
- return updateLogMetric(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates or updates a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * LogMetric metric = LogMetric.newBuilder().build();
- * UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder()
- * .setMetricName(formattedMetricName)
- * .setMetric(metric)
- * .build();
- * LogMetric response = metricsServiceV2Api.updateLogMetric(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final LogMetric updateLogMetric(UpdateLogMetricRequest request) {
- return updateLogMetricCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates or updates a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * LogMetric metric = LogMetric.newBuilder().build();
- * UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder()
- * .setMetricName(formattedMetricName)
- * .setMetric(metric)
- * .build();
- * ListenableFuture<LogMetric> future = metricsServiceV2Api.updateLogMetricCallable().futureCall(request);
- * // Do something
- * LogMetric response = future.get();
- * }
- *
- */
- public final ApiCallable updateLogMetricCallable() {
- return updateLogMetricCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * metricsServiceV2Api.deleteLogMetric(formattedMetricName);
- * }
- *
- *
- * @param metricName The resource name of the metric to delete.
- * Example: `"projects/my-project-id/metrics/my-metric-id"`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void deleteLogMetric(String metricName) {
- METRIC_PATH_TEMPLATE.validate(metricName, "deleteLogMetric");
- DeleteLogMetricRequest request =
- DeleteLogMetricRequest.newBuilder().setMetricName(metricName).build();
- deleteLogMetric(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder()
- * .setMetricName(formattedMetricName)
- * .build();
- * metricsServiceV2Api.deleteLogMetric(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final void deleteLogMetric(DeleteLogMetricRequest request) {
- deleteLogMetricCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes a logs-based metric.
- *
- * Sample code:
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder()
- * .setMetricName(formattedMetricName)
- * .build();
- * ListenableFuture<Void> future = metricsServiceV2Api.deleteLogMetricCallable().futureCall(request);
- * // Do something
- * future.get();
- * }
- *
- */
- public final ApiCallable deleteLogMetricCallable() {
- return deleteLogMetricCallable;
- }
-
- /**
- * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
- * cancelled.
- */
- @Override
- public final void close() throws Exception {
- for (AutoCloseable closeable : closeables) {
- closeable.close();
- }
- }
-}
diff --git a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java b/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java
deleted file mode 100644
index 9667eca31176..000000000000
--- a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.logging.spi.v2;
-
-import com.google.api.gax.core.ConnectionSettings;
-import com.google.api.gax.core.RetrySettings;
-import com.google.api.gax.grpc.ApiCallSettings;
-import com.google.api.gax.grpc.PageStreamingCallSettings;
-import com.google.api.gax.grpc.PageStreamingDescriptor;
-import com.google.api.gax.grpc.ServiceApiSettings;
-import com.google.api.gax.grpc.SimpleCallSettings;
-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.logging.v2.CreateLogMetricRequest;
-import com.google.logging.v2.DeleteLogMetricRequest;
-import com.google.logging.v2.GetLogMetricRequest;
-import com.google.logging.v2.ListLogMetricsRequest;
-import com.google.logging.v2.ListLogMetricsResponse;
-import com.google.logging.v2.LogMetric;
-import com.google.logging.v2.MetricsServiceV2Grpc;
-import com.google.logging.v2.UpdateLogMetricRequest;
-import com.google.protobuf.Empty;
-import io.grpc.ManagedChannel;
-import io.grpc.Status;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-import org.joda.time.Duration;
-
-// AUTO-GENERATED DOCUMENTATION AND CLASS
-/**
- * Settings class to configure an instance of {@link MetricsServiceV2Api}.
- *
- * The default instance has everything set to sensible defaults:
- *
- *
- * - The default service address (logging.googleapis.com) and default port (443)
- * 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 getLogMetric to 30 seconds:
- *
- *
- *
- * MetricsServiceV2Settings.Builder metricsServiceV2SettingsBuilder =
- * MetricsServiceV2Settings.defaultBuilder();
- * metricsServiceV2SettingsBuilder.getLogMetricSettings().getRetrySettingsBuilder()
- * .setTotalTimeout(Duration.standardSeconds(30));
- * MetricsServiceV2Settings metricsServiceV2Settings = metricsServiceV2SettingsBuilder.build();
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class MetricsServiceV2Settings extends ServiceApiSettings {
- /**
- * The default address of the service.
- */
- private static final String DEFAULT_SERVICE_ADDRESS = "logging.googleapis.com";
-
- /**
- * The default port of the service.
- */
- private static final int DEFAULT_SERVICE_PORT = 443;
-
- /**
- * 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/cloud-platform.read-only")
- .add("https://www.googleapis.com/auth/logging.admin")
- .add("https://www.googleapis.com/auth/logging.read")
- .add("https://www.googleapis.com/auth/logging.write")
- .build();
-
- /**
- * The default connection settings of the service.
- */
- public static final ConnectionSettings DEFAULT_CONNECTION_SETTINGS =
- ConnectionSettings.newBuilder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build();
-
- private final PageStreamingCallSettings
- listLogMetricsSettings;
- private final SimpleCallSettings getLogMetricSettings;
- private final SimpleCallSettings createLogMetricSettings;
- private final SimpleCallSettings updateLogMetricSettings;
- private final SimpleCallSettings deleteLogMetricSettings;
-
- /**
- * Returns the object with the settings used for calls to listLogMetrics.
- */
- public PageStreamingCallSettings
- listLogMetricsSettings() {
- return listLogMetricsSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to getLogMetric.
- */
- public SimpleCallSettings getLogMetricSettings() {
- return getLogMetricSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to createLogMetric.
- */
- public SimpleCallSettings createLogMetricSettings() {
- return createLogMetricSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to updateLogMetric.
- */
- public SimpleCallSettings updateLogMetricSettings() {
- return updateLogMetricSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to deleteLogMetric.
- */
- public SimpleCallSettings deleteLogMetricSettings() {
- return deleteLogMetricSettings;
- }
-
- /**
- * Returns the default service address.
- */
- public static String getDefaultServiceAddress() {
- return DEFAULT_SERVICE_ADDRESS;
- }
-
- /**
- * Returns the default service port.
- */
- public static int getDefaultServicePort() {
- return DEFAULT_SERVICE_PORT;
- }
-
- /**
- * Returns the default service scopes.
- */
- public static ImmutableList getDefaultServiceScopes() {
- return DEFAULT_SERVICE_SCOPES;
- }
-
- /**
- * Returns a builder for this class with recommended defaults.
- */
- public static Builder defaultBuilder() {
- return Builder.createDefault();
- }
-
- /**
- * Returns a new builder for this class.
- */
- public static Builder newBuilder() {
- return new Builder();
- }
-
- /**
- * Returns a builder containing all the values of this settings class.
- */
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- private MetricsServiceV2Settings(Builder settingsBuilder) throws IOException {
- super(
- settingsBuilder.getChannelProvider(),
- settingsBuilder.getExecutorProvider(),
- settingsBuilder.getGeneratorName(),
- settingsBuilder.getGeneratorVersion(),
- settingsBuilder.getClientLibName(),
- settingsBuilder.getClientLibVersion());
-
- listLogMetricsSettings = settingsBuilder.listLogMetricsSettings().build();
- getLogMetricSettings = settingsBuilder.getLogMetricSettings().build();
- createLogMetricSettings = settingsBuilder.createLogMetricSettings().build();
- updateLogMetricSettings = settingsBuilder.updateLogMetricSettings().build();
- deleteLogMetricSettings = settingsBuilder.deleteLogMetricSettings().build();
- }
-
- private static PageStreamingDescriptor
- LIST_LOG_METRICS_PAGE_STR_DESC =
- new PageStreamingDescriptor() {
- @Override
- public Object emptyToken() {
- return "";
- }
-
- @Override
- public ListLogMetricsRequest injectToken(ListLogMetricsRequest payload, Object token) {
- return ListLogMetricsRequest.newBuilder(payload).setPageToken((String) token).build();
- }
-
- @Override
- public Object extractNextToken(ListLogMetricsResponse payload) {
- return payload.getNextPageToken();
- }
-
- @Override
- public Iterable extractResources(ListLogMetricsResponse payload) {
- return payload.getMetricsList();
- }
- };
-
- /**
- * Builder for MetricsServiceV2Settings.
- */
- public static class Builder extends ServiceApiSettings.Builder {
- private final ImmutableList methodSettingsBuilders;
-
- private PageStreamingCallSettings.Builder<
- ListLogMetricsRequest, ListLogMetricsResponse, LogMetric>
- listLogMetricsSettings;
- private SimpleCallSettings.Builder getLogMetricSettings;
- private SimpleCallSettings.Builder createLogMetricSettings;
- private SimpleCallSettings.Builder updateLogMetricSettings;
- private SimpleCallSettings.Builder deleteLogMetricSettings;
-
- private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS;
-
- static {
- ImmutableMap.Builder> definitions = ImmutableMap.builder();
- definitions.put(
- "idempotent",
- Sets.immutableEnumSet(
- Lists.newArrayList(
- Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE)));
- definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList()));
- RETRYABLE_CODE_DEFINITIONS = definitions.build();
- }
-
- private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
-
- static {
- ImmutableMap.Builder definitions = ImmutableMap.builder();
- RetrySettings.Builder settingsBuilder = null;
- settingsBuilder =
- RetrySettings.newBuilder()
- .setInitialRetryDelay(Duration.millis(100L))
- .setRetryDelayMultiplier(1.2)
- .setMaxRetryDelay(Duration.millis(1000L))
- .setInitialRpcTimeout(Duration.millis(2000L))
- .setRpcTimeoutMultiplier(1.5)
- .setMaxRpcTimeout(Duration.millis(30000L))
- .setTotalTimeout(Duration.millis(45000L));
- definitions.put("default", settingsBuilder);
- RETRY_PARAM_DEFINITIONS = definitions.build();
- }
-
- private Builder() {
- super(DEFAULT_CONNECTION_SETTINGS);
-
- listLogMetricsSettings =
- PageStreamingCallSettings.newBuilder(
- MetricsServiceV2Grpc.METHOD_LIST_LOG_METRICS, LIST_LOG_METRICS_PAGE_STR_DESC);
-
- getLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_GET_LOG_METRIC);
-
- createLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_CREATE_LOG_METRIC);
-
- updateLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_UPDATE_LOG_METRIC);
-
- deleteLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_DELETE_LOG_METRIC);
-
- methodSettingsBuilders =
- ImmutableList.of(
- listLogMetricsSettings,
- getLogMetricSettings,
- createLogMetricSettings,
- updateLogMetricSettings,
- deleteLogMetricSettings);
- }
-
- private static Builder createDefault() {
- Builder builder = new Builder();
-
- builder
- .listLogMetricsSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .getLogMetricSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .createLogMetricSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .updateLogMetricSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .deleteLogMetricSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- return builder;
- }
-
- private Builder(MetricsServiceV2Settings settings) {
- super(settings);
-
- listLogMetricsSettings = settings.listLogMetricsSettings.toBuilder();
- getLogMetricSettings = settings.getLogMetricSettings.toBuilder();
- createLogMetricSettings = settings.createLogMetricSettings.toBuilder();
- updateLogMetricSettings = settings.updateLogMetricSettings.toBuilder();
- deleteLogMetricSettings = settings.deleteLogMetricSettings.toBuilder();
-
- methodSettingsBuilders =
- ImmutableList.of(
- listLogMetricsSettings,
- getLogMetricSettings,
- createLogMetricSettings,
- updateLogMetricSettings,
- deleteLogMetricSettings);
- }
-
- @Override
- protected ConnectionSettings getDefaultConnectionSettings() {
- return DEFAULT_CONNECTION_SETTINGS;
- }
-
- @Override
- public Builder provideExecutorWith(ScheduledExecutorService executor, boolean shouldAutoClose) {
- super.provideExecutorWith(executor, shouldAutoClose);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(ManagedChannel channel, boolean shouldAutoClose) {
- super.provideChannelWith(channel, shouldAutoClose);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(ConnectionSettings settings) {
- super.provideChannelWith(settings);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(Credentials credentials) {
- super.provideChannelWith(credentials);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(List scopes) {
- super.provideChannelWith(scopes);
- return this;
- }
-
- @Override
- public Builder setGeneratorHeader(String name, String version) {
- super.setGeneratorHeader(name, version);
- return this;
- }
-
- @Override
- public Builder setClientLibHeader(String name, String version) {
- super.setClientLibHeader(name, version);
- return this;
- }
-
- /**
- * Applies the given settings to all of the API methods in this service. Only
- * values that are non-null will be applied, so this method is not capable
- * of un-setting any values.
- */
- public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception {
- super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings);
- return this;
- }
-
- /**
- * Returns the builder for the settings used for calls to listLogMetrics.
- */
- public PageStreamingCallSettings.Builder<
- ListLogMetricsRequest, ListLogMetricsResponse, LogMetric>
- listLogMetricsSettings() {
- return listLogMetricsSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to getLogMetric.
- */
- public SimpleCallSettings.Builder getLogMetricSettings() {
- return getLogMetricSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to createLogMetric.
- */
- public SimpleCallSettings.Builder createLogMetricSettings() {
- return createLogMetricSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to updateLogMetric.
- */
- public SimpleCallSettings.Builder updateLogMetricSettings() {
- return updateLogMetricSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to deleteLogMetric.
- */
- public SimpleCallSettings.Builder deleteLogMetricSettings() {
- return deleteLogMetricSettings;
- }
-
- @Override
- public MetricsServiceV2Settings build() throws IOException {
- return new MetricsServiceV2Settings(this);
- }
- }
-}
diff --git a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/package-info.java b/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/package-info.java
deleted file mode 100644
index 30c648516059..000000000000
--- a/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/package-info.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-/**
- * A client to Google Cloud Logging API.
- *
- * The interfaces provided are listed below, along with a usage sample
- *
- * ==================
- * ConfigServiceV2Api
- * ==================
- *
- * Service Description: Service for configuring sinks used to export log entries outside Stackdriver
- * Logging.
- *
- * Sample for ConfigServiceV2Api:
- *
- *
- * try (ConfigServiceV2Api configServiceV2Api = ConfigServiceV2Api.create()) {
- * String formattedSinkName = ConfigServiceV2Api.formatSinkName("[PROJECT]", "[SINK]");
- * LogSink response = configServiceV2Api.getSink(formattedSinkName);
- * }
- *
- *
- *
- * ===================
- * MetricsServiceV2Api
- * ===================
- *
- * Service Description: Service for configuring logs-based metrics.
- *
- * Sample for MetricsServiceV2Api:
- *
- *
- * try (MetricsServiceV2Api metricsServiceV2Api = MetricsServiceV2Api.create()) {
- * String formattedMetricName = MetricsServiceV2Api.formatMetricName("[PROJECT]", "[METRIC]");
- * LogMetric response = metricsServiceV2Api.getLogMetric(formattedMetricName);
- * }
- *
- *
- *
- * ===================
- * LoggingServiceV2Api
- * ===================
- *
- * Service Description: Service for ingesting and querying logs.
- *
- * Sample for LoggingServiceV2Api:
- *
- *
- * try (LoggingServiceV2Api loggingServiceV2Api = LoggingServiceV2Api.create()) {
- * String formattedLogName = LoggingServiceV2Api.formatLogName("[PROJECT]", "[LOG]");
- * loggingServiceV2Api.deleteLog(formattedLogName);
- * }
- *
- *
- *
- */
-package com.google.cloud.logging.spi.v2;
diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherApi.java
deleted file mode 100644
index 199280657158..000000000000
--- a/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherApi.java
+++ /dev/null
@@ -1,739 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.pubsub.spi.v1;
-
-import com.google.api.gax.core.PageAccessor;
-import com.google.api.gax.grpc.ApiCallable;
-import com.google.api.gax.protobuf.PathTemplate;
-import com.google.protobuf.ByteString;
-import com.google.protobuf.Empty;
-import com.google.pubsub.v1.DeleteTopicRequest;
-import com.google.pubsub.v1.GetTopicRequest;
-import com.google.pubsub.v1.ListTopicSubscriptionsRequest;
-import com.google.pubsub.v1.ListTopicSubscriptionsResponse;
-import com.google.pubsub.v1.ListTopicsRequest;
-import com.google.pubsub.v1.ListTopicsResponse;
-import com.google.pubsub.v1.PublishRequest;
-import com.google.pubsub.v1.PublishResponse;
-import com.google.pubsub.v1.PubsubMessage;
-import com.google.pubsub.v1.Topic;
-import io.grpc.ManagedChannel;
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-
-// AUTO-GENERATED DOCUMENTATION AND SERVICE
-/**
- * Service Description: The service that an application uses to manipulate topics, and to send
- * messages to a topic.
- *
- * 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 (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedName = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * Topic response = publisherApi.createTopic(formattedName);
- * }
- *
- *
- *
- * Note: close() needs to be called on the publisherApi 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:
- *
- *
- * - 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.
- *
- 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.
- *
- A "callable" method. This type of method takes no parameters and returns an immutable
- * ApiCallable 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 PublisherSettings to
- * create(). For example:
- *
- *
- *
- * PublisherSettings publisherSettings = PublisherSettings.defaultBuilder()
- * .provideChannelWith(myCredentials)
- * .build();
- * PublisherApi publisherApi = PublisherApi.create(publisherSettings);
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class PublisherApi implements AutoCloseable {
- private final PublisherSettings settings;
- private final ManagedChannel channel;
- private final ScheduledExecutorService executor;
- private final List closeables = new ArrayList<>();
-
- private final ApiCallable createTopicCallable;
- private final ApiCallable publishCallable;
- private final ApiCallable getTopicCallable;
- private final ApiCallable listTopicsCallable;
- private final ApiCallable> listTopicsPagedCallable;
- private final ApiCallable
- listTopicSubscriptionsCallable;
- private final ApiCallable>
- listTopicSubscriptionsPagedCallable;
- private final ApiCallable deleteTopicCallable;
-
- public final PublisherSettings getSettings() {
- return settings;
- }
-
- private static final PathTemplate PROJECT_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}");
-
- private static final PathTemplate TOPIC_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/topics/{topic}");
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a project resource.
- */
- public static final String formatProjectName(String project) {
- return PROJECT_PATH_TEMPLATE.instantiate("project", project);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a topic resource.
- */
- public static final String formatTopicName(String project, String topic) {
- return TOPIC_PATH_TEMPLATE.instantiate(
- "project", project,
- "topic", topic);
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a project resource.
- */
- public static final String parseProjectFromProjectName(String projectName) {
- return PROJECT_PATH_TEMPLATE.parse(projectName).get("project");
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a topic resource.
- */
- public static final String parseProjectFromTopicName(String topicName) {
- return TOPIC_PATH_TEMPLATE.parse(topicName).get("project");
- }
-
- /**
- * Parses the topic from the given fully-qualified path which
- * represents a topic resource.
- */
- public static final String parseTopicFromTopicName(String topicName) {
- return TOPIC_PATH_TEMPLATE.parse(topicName).get("topic");
- }
-
- /**
- * Constructs an instance of PublisherApi with default settings.
- */
- public static final PublisherApi create() throws IOException {
- return create(PublisherSettings.defaultBuilder().build());
- }
-
- /**
- * Constructs an instance of PublisherApi, 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 PublisherApi create(PublisherSettings settings) throws IOException {
- return new PublisherApi(settings);
- }
-
- /**
- * Constructs an instance of PublisherApi, using the given settings.
- * This is protected so that it easy to make a subclass, but otherwise, the static
- * factory methods should be preferred.
- */
- protected PublisherApi(PublisherSettings settings) throws IOException {
- this.settings = settings;
- this.executor = settings.getExecutorProvider().getOrBuildExecutor();
- this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
-
- this.createTopicCallable =
- ApiCallable.create(settings.createTopicSettings(), this.channel, this.executor);
- this.publishCallable =
- ApiCallable.create(settings.publishSettings(), this.channel, this.executor);
- if (settings.publishSettings().getBundlerFactory() != null) {
- closeables.add(settings.publishSettings().getBundlerFactory());
- }
- this.getTopicCallable =
- ApiCallable.create(settings.getTopicSettings(), this.channel, this.executor);
- this.listTopicsCallable =
- ApiCallable.create(settings.listTopicsSettings(), this.channel, this.executor);
- this.listTopicsPagedCallable =
- ApiCallable.createPagedVariant(settings.listTopicsSettings(), this.channel, this.executor);
- this.listTopicSubscriptionsCallable =
- ApiCallable.create(settings.listTopicSubscriptionsSettings(), this.channel, this.executor);
- this.listTopicSubscriptionsPagedCallable =
- ApiCallable.createPagedVariant(
- settings.listTopicSubscriptionsSettings(), this.channel, this.executor);
- this.deleteTopicCallable =
- ApiCallable.create(settings.deleteTopicSettings(), this.channel, this.executor);
-
- if (settings.getChannelProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- channel.shutdown();
- }
- });
- }
- if (settings.getExecutorProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- executor.shutdown();
- }
- });
- }
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates the given topic with the given name.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedName = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * Topic response = publisherApi.createTopic(formattedName);
- * }
- *
- *
- * @param name The name of the topic. It must have the format
- * `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
- * and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
- * underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
- * signs (`%`). It must be between 3 and 255 characters in length, and it
- * must not start with `"goog"`.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final Topic createTopic(String name) {
- TOPIC_PATH_TEMPLATE.validate(name, "createTopic");
- Topic request = Topic.newBuilder().setName(name).build();
- return createTopic(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates the given topic with the given name.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedName = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * Topic request = Topic.newBuilder()
- * .setName(formattedName)
- * .build();
- * Topic response = publisherApi.createTopic(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final Topic createTopic(Topic request) {
- return createTopicCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates the given topic with the given name.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedName = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * Topic request = Topic.newBuilder()
- * .setName(formattedName)
- * .build();
- * ListenableFuture<Topic> future = publisherApi.createTopicCallable().futureCall(request);
- * // Do something
- * Topic response = future.get();
- * }
- *
- */
- public final ApiCallable createTopicCallable() {
- return createTopicCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
- * does not exist. The message payload must not be empty; it must contain
- * either a non-empty data field, or at least one attribute.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * ByteString data = ByteString.copyFromUtf8("");
- * PubsubMessage messagesElement = PubsubMessage.newBuilder()
- * .setData(data)
- * .build();
- * List<PubsubMessage> messages = Arrays.asList(messagesElement);
- * PublishResponse response = publisherApi.publish(formattedTopic, messages);
- * }
- *
- *
- * @param topic The messages in the request will be published on this topic.
- * @param messages The messages to publish.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PublishResponse publish(String topic, List messages) {
- TOPIC_PATH_TEMPLATE.validate(topic, "publish");
- PublishRequest request =
- PublishRequest.newBuilder().setTopic(topic).addAllMessages(messages).build();
- return publish(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
- * does not exist. The message payload must not be empty; it must contain
- * either a non-empty data field, or at least one attribute.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * ByteString data = ByteString.copyFromUtf8("");
- * PubsubMessage messagesElement = PubsubMessage.newBuilder()
- * .setData(data)
- * .build();
- * List<PubsubMessage> messages = Arrays.asList(messagesElement);
- * PublishRequest request = PublishRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .addAllMessages(messages)
- * .build();
- * PublishResponse response = publisherApi.publish(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PublishResponse publish(PublishRequest request) {
- return publishCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
- * does not exist. The message payload must not be empty; it must contain
- * either a non-empty data field, or at least one attribute.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * ByteString data = ByteString.copyFromUtf8("");
- * PubsubMessage messagesElement = PubsubMessage.newBuilder()
- * .setData(data)
- * .build();
- * List<PubsubMessage> messages = Arrays.asList(messagesElement);
- * PublishRequest request = PublishRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .addAllMessages(messages)
- * .build();
- * ListenableFuture<PublishResponse> future = publisherApi.publishCallable().futureCall(request);
- * // Do something
- * PublishResponse response = future.get();
- * }
- *
- */
- public final ApiCallable publishCallable() {
- return publishCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets the configuration of a topic.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * Topic response = publisherApi.getTopic(formattedTopic);
- * }
- *
- *
- * @param topic The name of the topic to get.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final Topic getTopic(String topic) {
- TOPIC_PATH_TEMPLATE.validate(topic, "getTopic");
- GetTopicRequest request = GetTopicRequest.newBuilder().setTopic(topic).build();
- return getTopic(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets the configuration of a topic.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * GetTopicRequest request = GetTopicRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .build();
- * Topic response = publisherApi.getTopic(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final Topic getTopic(GetTopicRequest request) {
- return getTopicCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets the configuration of a topic.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * GetTopicRequest request = GetTopicRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .build();
- * ListenableFuture<Topic> future = publisherApi.getTopicCallable().futureCall(request);
- * // Do something
- * Topic response = future.get();
- * }
- *
- */
- public final ApiCallable getTopicCallable() {
- return getTopicCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists matching topics.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedProject = PublisherApi.formatProjectName("[PROJECT]");
- * for (Topic element : publisherApi.listTopics(formattedProject)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param project The name of the cloud project that topics belong to.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listTopics(String project) {
- PROJECT_PATH_TEMPLATE.validate(project, "listTopics");
- ListTopicsRequest request = ListTopicsRequest.newBuilder().setProject(project).build();
- return listTopics(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists matching topics.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedProject = PublisherApi.formatProjectName("[PROJECT]");
- * ListTopicsRequest request = ListTopicsRequest.newBuilder()
- * .setProject(formattedProject)
- * .build();
- * for (Topic element : publisherApi.listTopics(request)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listTopics(ListTopicsRequest request) {
- return listTopicsPagedCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists matching topics.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedProject = PublisherApi.formatProjectName("[PROJECT]");
- * ListTopicsRequest request = ListTopicsRequest.newBuilder()
- * .setProject(formattedProject)
- * .build();
- * ListenableFuture<PageAccessor<Topic>> future = publisherApi.listTopicsPagedCallable().futureCall(request);
- * // Do something
- * for (Topic element : future.get()) {
- * // doThingsWith(element);
- * }
- * }
- *
- */
- public final ApiCallable> listTopicsPagedCallable() {
- return listTopicsPagedCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists matching topics.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedProject = PublisherApi.formatProjectName("[PROJECT]");
- * ListTopicsRequest request = ListTopicsRequest.newBuilder()
- * .setProject(formattedProject)
- * .build();
- * while (true) {
- * ListTopicsResponse response = publisherApi.listTopicsCallable().call(request);
- * for (Topic element : response.getTopicsList()) {
- * // doThingsWith(element);
- * }
- * String nextPageToken = response.getNextPageToken();
- * if (!Strings.isNullOrEmpty(nextPageToken)) {
- * request = request.toBuilder().setPageToken(nextPageToken).build();
- * } else {
- * break;
- * }
- * }
- * }
- *
- */
- public final ApiCallable listTopicsCallable() {
- return listTopicsCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists the name of the subscriptions for this topic.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * for (String element : publisherApi.listTopicSubscriptions(formattedTopic)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param topic The name of the topic that subscriptions are attached to.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listTopicSubscriptions(String topic) {
- TOPIC_PATH_TEMPLATE.validate(topic, "listTopicSubscriptions");
- ListTopicSubscriptionsRequest request =
- ListTopicSubscriptionsRequest.newBuilder().setTopic(topic).build();
- return listTopicSubscriptions(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists the name of the subscriptions for this topic.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * ListTopicSubscriptionsRequest request = ListTopicSubscriptionsRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .build();
- * for (String element : publisherApi.listTopicSubscriptions(request)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listTopicSubscriptions(ListTopicSubscriptionsRequest request) {
- return listTopicSubscriptionsPagedCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists the name of the subscriptions for this topic.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * ListTopicSubscriptionsRequest request = ListTopicSubscriptionsRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .build();
- * ListenableFuture<PageAccessor<String>> future = publisherApi.listTopicSubscriptionsPagedCallable().futureCall(request);
- * // Do something
- * for (String element : future.get()) {
- * // doThingsWith(element);
- * }
- * }
- *
- */
- public final ApiCallable>
- listTopicSubscriptionsPagedCallable() {
- return listTopicSubscriptionsPagedCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists the name of the subscriptions for this topic.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * ListTopicSubscriptionsRequest request = ListTopicSubscriptionsRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .build();
- * while (true) {
- * ListTopicSubscriptionsResponse response = publisherApi.listTopicSubscriptionsCallable().call(request);
- * for (String element : response.getSubscriptionsList()) {
- * // doThingsWith(element);
- * }
- * String nextPageToken = response.getNextPageToken();
- * if (!Strings.isNullOrEmpty(nextPageToken)) {
- * request = request.toBuilder().setPageToken(nextPageToken).build();
- * } else {
- * break;
- * }
- * }
- * }
- *
- */
- public final ApiCallable
- listTopicSubscriptionsCallable() {
- return listTopicSubscriptionsCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
- * does not exist. After a topic is deleted, a new topic may be created with
- * the same name; this is an entirely new topic with none of the old
- * configuration or subscriptions. Existing subscriptions to this topic are
- * not deleted, but their `topic` field is set to `_deleted-topic_`.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * publisherApi.deleteTopic(formattedTopic);
- * }
- *
- *
- * @param topic Name of the topic to delete.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void deleteTopic(String topic) {
- TOPIC_PATH_TEMPLATE.validate(topic, "deleteTopic");
- DeleteTopicRequest request = DeleteTopicRequest.newBuilder().setTopic(topic).build();
- deleteTopic(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
- * does not exist. After a topic is deleted, a new topic may be created with
- * the same name; this is an entirely new topic with none of the old
- * configuration or subscriptions. Existing subscriptions to this topic are
- * not deleted, but their `topic` field is set to `_deleted-topic_`.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * DeleteTopicRequest request = DeleteTopicRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .build();
- * publisherApi.deleteTopic(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final void deleteTopic(DeleteTopicRequest request) {
- deleteTopicCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
- * does not exist. After a topic is deleted, a new topic may be created with
- * the same name; this is an entirely new topic with none of the old
- * configuration or subscriptions. Existing subscriptions to this topic are
- * not deleted, but their `topic` field is set to `_deleted-topic_`.
- *
- * Sample code:
- *
- * try (PublisherApi publisherApi = PublisherApi.create()) {
- * String formattedTopic = PublisherApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * DeleteTopicRequest request = DeleteTopicRequest.newBuilder()
- * .setTopic(formattedTopic)
- * .build();
- * ListenableFuture<Void> future = publisherApi.deleteTopicCallable().futureCall(request);
- * // Do something
- * future.get();
- * }
- *
- */
- public final ApiCallable deleteTopicCallable() {
- return deleteTopicCallable;
- }
-
- /**
- * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
- * cancelled.
- */
- @Override
- public final void close() throws Exception {
- for (AutoCloseable closeable : closeables) {
- closeable.close();
- }
- }
-}
diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherSettings.java
deleted file mode 100644
index f91bc59e9658..000000000000
--- a/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/PublisherSettings.java
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.pubsub.spi.v1;
-
-import com.google.api.gax.core.ConnectionSettings;
-import com.google.api.gax.core.RetrySettings;
-import com.google.api.gax.grpc.ApiCallSettings;
-import com.google.api.gax.grpc.BundlingCallSettings;
-import com.google.api.gax.grpc.BundlingDescriptor;
-import com.google.api.gax.grpc.BundlingSettings;
-import com.google.api.gax.grpc.PageStreamingCallSettings;
-import com.google.api.gax.grpc.PageStreamingDescriptor;
-import com.google.api.gax.grpc.RequestIssuer;
-import com.google.api.gax.grpc.ServiceApiSettings;
-import com.google.api.gax.grpc.SimpleCallSettings;
-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.protobuf.Empty;
-import com.google.pubsub.v1.DeleteTopicRequest;
-import com.google.pubsub.v1.GetTopicRequest;
-import com.google.pubsub.v1.ListTopicSubscriptionsRequest;
-import com.google.pubsub.v1.ListTopicSubscriptionsResponse;
-import com.google.pubsub.v1.ListTopicsRequest;
-import com.google.pubsub.v1.ListTopicsResponse;
-import com.google.pubsub.v1.PublishRequest;
-import com.google.pubsub.v1.PublishResponse;
-import com.google.pubsub.v1.PublisherGrpc;
-import com.google.pubsub.v1.PubsubMessage;
-import com.google.pubsub.v1.Topic;
-import io.grpc.ManagedChannel;
-import io.grpc.Status;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-import org.joda.time.Duration;
-
-// AUTO-GENERATED DOCUMENTATION AND CLASS
-/**
- * Settings class to configure an instance of {@link PublisherApi}.
- *
- * The default instance has everything set to sensible defaults:
- *
- *
- * - The default service address (pubsub.googleapis.com) and default port (443)
- * 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 createTopic to 30 seconds:
- *
- *
- *
- * PublisherSettings.Builder publisherSettingsBuilder =
- * PublisherSettings.defaultBuilder();
- * publisherSettingsBuilder.createTopicSettings().getRetrySettingsBuilder()
- * .setTotalTimeout(Duration.standardSeconds(30));
- * PublisherSettings publisherSettings = publisherSettingsBuilder.build();
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class PublisherSettings extends ServiceApiSettings {
- /**
- * The default address of the service.
- */
- private static final String DEFAULT_SERVICE_ADDRESS = "pubsub.googleapis.com";
-
- /**
- * The default port of the service.
- */
- private static final int DEFAULT_SERVICE_PORT = 443;
-
- /**
- * 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/pubsub")
- .build();
-
- /**
- * The default connection settings of the service.
- */
- public static final ConnectionSettings DEFAULT_CONNECTION_SETTINGS =
- ConnectionSettings.newBuilder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build();
-
- private final SimpleCallSettings createTopicSettings;
- private final BundlingCallSettings publishSettings;
- private final SimpleCallSettings getTopicSettings;
- private final PageStreamingCallSettings
- listTopicsSettings;
- private final PageStreamingCallSettings<
- ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
- listTopicSubscriptionsSettings;
- private final SimpleCallSettings deleteTopicSettings;
-
- /**
- * Returns the object with the settings used for calls to createTopic.
- */
- public SimpleCallSettings createTopicSettings() {
- return createTopicSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to publish.
- */
- public BundlingCallSettings publishSettings() {
- return publishSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to getTopic.
- */
- public SimpleCallSettings getTopicSettings() {
- return getTopicSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to listTopics.
- */
- public PageStreamingCallSettings
- listTopicsSettings() {
- return listTopicsSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to listTopicSubscriptions.
- */
- public PageStreamingCallSettings<
- ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
- listTopicSubscriptionsSettings() {
- return listTopicSubscriptionsSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to deleteTopic.
- */
- public SimpleCallSettings deleteTopicSettings() {
- return deleteTopicSettings;
- }
-
- /**
- * Returns the default service address.
- */
- public static String getDefaultServiceAddress() {
- return DEFAULT_SERVICE_ADDRESS;
- }
-
- /**
- * Returns the default service port.
- */
- public static int getDefaultServicePort() {
- return DEFAULT_SERVICE_PORT;
- }
-
- /**
- * Returns the default service scopes.
- */
- public static ImmutableList getDefaultServiceScopes() {
- return DEFAULT_SERVICE_SCOPES;
- }
-
- /**
- * Returns a builder for this class with recommended defaults.
- */
- public static Builder defaultBuilder() {
- return Builder.createDefault();
- }
-
- /**
- * Returns a new builder for this class.
- */
- public static Builder newBuilder() {
- return new Builder();
- }
-
- /**
- * Returns a builder containing all the values of this settings class.
- */
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- private PublisherSettings(Builder settingsBuilder) throws IOException {
- super(
- settingsBuilder.getChannelProvider(),
- settingsBuilder.getExecutorProvider(),
- settingsBuilder.getGeneratorName(),
- settingsBuilder.getGeneratorVersion(),
- settingsBuilder.getClientLibName(),
- settingsBuilder.getClientLibVersion());
-
- createTopicSettings = settingsBuilder.createTopicSettings().build();
- publishSettings = settingsBuilder.publishSettings().build();
- getTopicSettings = settingsBuilder.getTopicSettings().build();
- listTopicsSettings = settingsBuilder.listTopicsSettings().build();
- listTopicSubscriptionsSettings = settingsBuilder.listTopicSubscriptionsSettings().build();
- deleteTopicSettings = settingsBuilder.deleteTopicSettings().build();
- }
-
- private static PageStreamingDescriptor
- LIST_TOPICS_PAGE_STR_DESC =
- new PageStreamingDescriptor() {
- @Override
- public Object emptyToken() {
- return "";
- }
-
- @Override
- public ListTopicsRequest injectToken(ListTopicsRequest payload, Object token) {
- return ListTopicsRequest.newBuilder(payload).setPageToken((String) token).build();
- }
-
- @Override
- public Object extractNextToken(ListTopicsResponse payload) {
- return payload.getNextPageToken();
- }
-
- @Override
- public Iterable extractResources(ListTopicsResponse payload) {
- return payload.getTopicsList();
- }
- };
-
- private static PageStreamingDescriptor<
- ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
- LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC =
- new PageStreamingDescriptor<
- ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>() {
- @Override
- public Object emptyToken() {
- return "";
- }
-
- @Override
- public ListTopicSubscriptionsRequest injectToken(
- ListTopicSubscriptionsRequest payload, Object token) {
- return ListTopicSubscriptionsRequest.newBuilder(payload)
- .setPageToken((String) token)
- .build();
- }
-
- @Override
- public Object extractNextToken(ListTopicSubscriptionsResponse payload) {
- return payload.getNextPageToken();
- }
-
- @Override
- public Iterable extractResources(ListTopicSubscriptionsResponse payload) {
- return payload.getSubscriptionsList();
- }
- };
-
- private static BundlingDescriptor PUBLISH_BUNDLING_DESC =
- new BundlingDescriptor() {
- @Override
- public String getBundlePartitionKey(PublishRequest request) {
- return request.getTopic() + "|";
- }
-
- @Override
- public PublishRequest mergeRequests(Collection requests) {
- PublishRequest firstRequest = requests.iterator().next();
-
- List elements = new ArrayList<>();
- for (PublishRequest request : requests) {
- elements.addAll(request.getMessagesList());
- }
-
- PublishRequest bundleRequest =
- PublishRequest.newBuilder()
- .setTopic(firstRequest.getTopic())
- .addAllMessages(elements)
- .build();
- return bundleRequest;
- }
-
- @Override
- public void splitResponse(
- PublishResponse bundleResponse,
- Collection extends RequestIssuer> bundle) {
- int bundleMessageIndex = 0;
- for (RequestIssuer responder : bundle) {
- List subresponseElements = new ArrayList<>();
- int subresponseCount = responder.getRequest().getMessagesCount();
- for (int i = 0; i < subresponseCount; i++) {
- subresponseElements.add(bundleResponse.getMessageIds(bundleMessageIndex));
- bundleMessageIndex += 1;
- }
- PublishResponse response =
- PublishResponse.newBuilder().addAllMessageIds(subresponseElements).build();
- responder.setResponse(response);
- }
- }
-
- @Override
- public void splitException(
- Throwable throwable,
- Collection extends RequestIssuer> bundle) {
- for (RequestIssuer responder : bundle) {
- responder.setException(throwable);
- }
- }
-
- @Override
- public long countElements(PublishRequest request) {
- return request.getMessagesCount();
- }
-
- @Override
- public long countBytes(PublishRequest request) {
- return request.getSerializedSize();
- }
- };
-
- /**
- * Builder for PublisherSettings.
- */
- public static class Builder extends ServiceApiSettings.Builder {
- private final ImmutableList methodSettingsBuilders;
-
- private SimpleCallSettings.Builder createTopicSettings;
- private BundlingCallSettings.Builder publishSettings;
- private SimpleCallSettings.Builder getTopicSettings;
- private PageStreamingCallSettings.Builder
- listTopicsSettings;
- private PageStreamingCallSettings.Builder<
- ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
- listTopicSubscriptionsSettings;
- private SimpleCallSettings.Builder deleteTopicSettings;
-
- private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS;
-
- static {
- ImmutableMap.Builder> definitions = ImmutableMap.builder();
- definitions.put(
- "idempotent",
- Sets.immutableEnumSet(
- Lists.newArrayList(
- Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE)));
- definitions.put(
- "one_plus_delivery",
- Sets.immutableEnumSet(
- Lists.newArrayList(
- Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE)));
- definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList()));
- RETRYABLE_CODE_DEFINITIONS = definitions.build();
- }
-
- private static final ImmutableMap RETRY_PARAM_DEFINITIONS;
-
- static {
- ImmutableMap.Builder definitions = ImmutableMap.builder();
- RetrySettings.Builder settingsBuilder = null;
- settingsBuilder =
- RetrySettings.newBuilder()
- .setInitialRetryDelay(Duration.millis(100L))
- .setRetryDelayMultiplier(1.3)
- .setMaxRetryDelay(Duration.millis(60000L))
- .setInitialRpcTimeout(Duration.millis(60000L))
- .setRpcTimeoutMultiplier(1.0)
- .setMaxRpcTimeout(Duration.millis(60000L))
- .setTotalTimeout(Duration.millis(600000L));
- definitions.put("default", settingsBuilder);
- settingsBuilder =
- RetrySettings.newBuilder()
- .setInitialRetryDelay(Duration.millis(100L))
- .setRetryDelayMultiplier(1.3)
- .setMaxRetryDelay(Duration.millis(60000L))
- .setInitialRpcTimeout(Duration.millis(12000L))
- .setRpcTimeoutMultiplier(1.0)
- .setMaxRpcTimeout(Duration.millis(12000L))
- .setTotalTimeout(Duration.millis(600000L));
- definitions.put("messaging", settingsBuilder);
- RETRY_PARAM_DEFINITIONS = definitions.build();
- }
-
- private Builder() {
- super(DEFAULT_CONNECTION_SETTINGS);
-
- createTopicSettings = SimpleCallSettings.newBuilder(PublisherGrpc.METHOD_CREATE_TOPIC);
-
- publishSettings =
- BundlingCallSettings.newBuilder(PublisherGrpc.METHOD_PUBLISH, PUBLISH_BUNDLING_DESC)
- .setBundlingSettingsBuilder(BundlingSettings.newBuilder());
-
- getTopicSettings = SimpleCallSettings.newBuilder(PublisherGrpc.METHOD_GET_TOPIC);
-
- listTopicsSettings =
- PageStreamingCallSettings.newBuilder(
- PublisherGrpc.METHOD_LIST_TOPICS, LIST_TOPICS_PAGE_STR_DESC);
-
- listTopicSubscriptionsSettings =
- PageStreamingCallSettings.newBuilder(
- PublisherGrpc.METHOD_LIST_TOPIC_SUBSCRIPTIONS,
- LIST_TOPIC_SUBSCRIPTIONS_PAGE_STR_DESC);
-
- deleteTopicSettings = SimpleCallSettings.newBuilder(PublisherGrpc.METHOD_DELETE_TOPIC);
-
- methodSettingsBuilders =
- ImmutableList.of(
- createTopicSettings,
- publishSettings,
- getTopicSettings,
- listTopicsSettings,
- listTopicSubscriptionsSettings,
- deleteTopicSettings);
- }
-
- private static Builder createDefault() {
- Builder builder = new Builder();
-
- builder
- .createTopicSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .publishSettings()
- .getBundlingSettingsBuilder()
- .setElementCountThreshold(10)
- .setElementCountLimit(1000)
- .setRequestByteThreshold(1024)
- .setRequestByteLimit(10485760)
- .setDelayThreshold(Duration.millis(10))
- .setBlockingCallCountThreshold(1);
- builder
- .publishSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("one_plus_delivery"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("messaging"));
-
- builder
- .getTopicSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .listTopicsSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .listTopicSubscriptionsSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- builder
- .deleteTopicSettings()
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- return builder;
- }
-
- private Builder(PublisherSettings settings) {
- super(settings);
-
- createTopicSettings = settings.createTopicSettings.toBuilder();
- publishSettings = settings.publishSettings.toBuilder();
- getTopicSettings = settings.getTopicSettings.toBuilder();
- listTopicsSettings = settings.listTopicsSettings.toBuilder();
- listTopicSubscriptionsSettings = settings.listTopicSubscriptionsSettings.toBuilder();
- deleteTopicSettings = settings.deleteTopicSettings.toBuilder();
-
- methodSettingsBuilders =
- ImmutableList.of(
- createTopicSettings,
- publishSettings,
- getTopicSettings,
- listTopicsSettings,
- listTopicSubscriptionsSettings,
- deleteTopicSettings);
- }
-
- @Override
- protected ConnectionSettings getDefaultConnectionSettings() {
- return DEFAULT_CONNECTION_SETTINGS;
- }
-
- @Override
- public Builder provideExecutorWith(ScheduledExecutorService executor, boolean shouldAutoClose) {
- super.provideExecutorWith(executor, shouldAutoClose);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(ManagedChannel channel, boolean shouldAutoClose) {
- super.provideChannelWith(channel, shouldAutoClose);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(ConnectionSettings settings) {
- super.provideChannelWith(settings);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(Credentials credentials) {
- super.provideChannelWith(credentials);
- return this;
- }
-
- @Override
- public Builder provideChannelWith(List scopes) {
- super.provideChannelWith(scopes);
- return this;
- }
-
- @Override
- public Builder setGeneratorHeader(String name, String version) {
- super.setGeneratorHeader(name, version);
- return this;
- }
-
- @Override
- public Builder setClientLibHeader(String name, String version) {
- super.setClientLibHeader(name, version);
- return this;
- }
-
- /**
- * Applies the given settings to all of the API methods in this service. Only
- * values that are non-null will be applied, so this method is not capable
- * of un-setting any values.
- */
- public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception {
- super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings);
- return this;
- }
-
- /**
- * Returns the builder for the settings used for calls to createTopic.
- */
- public SimpleCallSettings.Builder createTopicSettings() {
- return createTopicSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to publish.
- */
- public BundlingCallSettings.Builder publishSettings() {
- return publishSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to getTopic.
- */
- public SimpleCallSettings.Builder getTopicSettings() {
- return getTopicSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to listTopics.
- */
- public PageStreamingCallSettings.Builder
- listTopicsSettings() {
- return listTopicsSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to listTopicSubscriptions.
- */
- public PageStreamingCallSettings.Builder<
- ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse, String>
- listTopicSubscriptionsSettings() {
- return listTopicSubscriptionsSettings;
- }
-
- /**
- * Returns the builder for the settings used for calls to deleteTopic.
- */
- public SimpleCallSettings.Builder deleteTopicSettings() {
- return deleteTopicSettings;
- }
-
- @Override
- public PublisherSettings build() throws IOException {
- return new PublisherSettings(this);
- }
- }
-}
diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberApi.java
deleted file mode 100644
index 3952b74a3b73..000000000000
--- a/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberApi.java
+++ /dev/null
@@ -1,1007 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.pubsub.spi.v1;
-
-import com.google.api.gax.core.PageAccessor;
-import com.google.api.gax.grpc.ApiCallable;
-import com.google.api.gax.protobuf.PathTemplate;
-import com.google.protobuf.Empty;
-import com.google.pubsub.v1.AcknowledgeRequest;
-import com.google.pubsub.v1.DeleteSubscriptionRequest;
-import com.google.pubsub.v1.GetSubscriptionRequest;
-import com.google.pubsub.v1.ListSubscriptionsRequest;
-import com.google.pubsub.v1.ListSubscriptionsResponse;
-import com.google.pubsub.v1.ModifyAckDeadlineRequest;
-import com.google.pubsub.v1.ModifyPushConfigRequest;
-import com.google.pubsub.v1.PullRequest;
-import com.google.pubsub.v1.PullResponse;
-import com.google.pubsub.v1.PushConfig;
-import com.google.pubsub.v1.Subscription;
-import io.grpc.ManagedChannel;
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-
-// AUTO-GENERATED DOCUMENTATION AND SERVICE
-/**
- * Service Description: The service that an application uses to manipulate subscriptions and to
- * consume messages from a subscription via the `Pull` method.
- *
- * 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 (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedName = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * String formattedTopic = SubscriberApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * PushConfig pushConfig = PushConfig.newBuilder().build();
- * int ackDeadlineSeconds = 0;
- * Subscription response = subscriberApi.createSubscription(formattedName, formattedTopic, pushConfig, ackDeadlineSeconds);
- * }
- *
- *
- *
- * Note: close() needs to be called on the subscriberApi 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:
- *
- *
- * - 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.
- *
- 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.
- *
- A "callable" method. This type of method takes no parameters and returns an immutable
- * ApiCallable 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 SubscriberSettings to
- * create(). For example:
- *
- *
- *
- * SubscriberSettings subscriberSettings = SubscriberSettings.defaultBuilder()
- * .provideChannelWith(myCredentials)
- * .build();
- * SubscriberApi subscriberApi = SubscriberApi.create(subscriberSettings);
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class SubscriberApi implements AutoCloseable {
- private final SubscriberSettings settings;
- private final ManagedChannel channel;
- private final ScheduledExecutorService executor;
- private final List closeables = new ArrayList<>();
-
- private final ApiCallable createSubscriptionCallable;
- private final ApiCallable getSubscriptionCallable;
- private final ApiCallable
- listSubscriptionsCallable;
- private final ApiCallable>
- listSubscriptionsPagedCallable;
- private final ApiCallable deleteSubscriptionCallable;
- private final ApiCallable modifyAckDeadlineCallable;
- private final ApiCallable acknowledgeCallable;
- private final ApiCallable pullCallable;
- private final ApiCallable modifyPushConfigCallable;
-
- public final SubscriberSettings getSettings() {
- return settings;
- }
-
- private static final PathTemplate PROJECT_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}");
-
- private static final PathTemplate SUBSCRIPTION_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/subscriptions/{subscription}");
-
- private static final PathTemplate TOPIC_PATH_TEMPLATE =
- PathTemplate.createWithoutUrlEncoding("projects/{project}/topics/{topic}");
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a project resource.
- */
- public static final String formatProjectName(String project) {
- return PROJECT_PATH_TEMPLATE.instantiate("project", project);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a subscription resource.
- */
- public static final String formatSubscriptionName(String project, String subscription) {
- return SUBSCRIPTION_PATH_TEMPLATE.instantiate(
- "project", project,
- "subscription", subscription);
- }
-
- /**
- * Formats a string containing the fully-qualified path to represent
- * a topic resource.
- */
- public static final String formatTopicName(String project, String topic) {
- return TOPIC_PATH_TEMPLATE.instantiate(
- "project", project,
- "topic", topic);
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a project resource.
- */
- public static final String parseProjectFromProjectName(String projectName) {
- return PROJECT_PATH_TEMPLATE.parse(projectName).get("project");
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a subscription resource.
- */
- public static final String parseProjectFromSubscriptionName(String subscriptionName) {
- return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionName).get("project");
- }
-
- /**
- * Parses the subscription from the given fully-qualified path which
- * represents a subscription resource.
- */
- public static final String parseSubscriptionFromSubscriptionName(String subscriptionName) {
- return SUBSCRIPTION_PATH_TEMPLATE.parse(subscriptionName).get("subscription");
- }
-
- /**
- * Parses the project from the given fully-qualified path which
- * represents a topic resource.
- */
- public static final String parseProjectFromTopicName(String topicName) {
- return TOPIC_PATH_TEMPLATE.parse(topicName).get("project");
- }
-
- /**
- * Parses the topic from the given fully-qualified path which
- * represents a topic resource.
- */
- public static final String parseTopicFromTopicName(String topicName) {
- return TOPIC_PATH_TEMPLATE.parse(topicName).get("topic");
- }
-
- /**
- * Constructs an instance of SubscriberApi with default settings.
- */
- public static final SubscriberApi create() throws IOException {
- return create(SubscriberSettings.defaultBuilder().build());
- }
-
- /**
- * Constructs an instance of SubscriberApi, 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 SubscriberApi create(SubscriberSettings settings) throws IOException {
- return new SubscriberApi(settings);
- }
-
- /**
- * Constructs an instance of SubscriberApi, using the given settings.
- * This is protected so that it easy to make a subclass, but otherwise, the static
- * factory methods should be preferred.
- */
- protected SubscriberApi(SubscriberSettings settings) throws IOException {
- this.settings = settings;
- this.executor = settings.getExecutorProvider().getOrBuildExecutor();
- this.channel = settings.getChannelProvider().getOrBuildChannel(this.executor);
-
- this.createSubscriptionCallable =
- ApiCallable.create(settings.createSubscriptionSettings(), this.channel, this.executor);
- this.getSubscriptionCallable =
- ApiCallable.create(settings.getSubscriptionSettings(), this.channel, this.executor);
- this.listSubscriptionsCallable =
- ApiCallable.create(settings.listSubscriptionsSettings(), this.channel, this.executor);
- this.listSubscriptionsPagedCallable =
- ApiCallable.createPagedVariant(
- settings.listSubscriptionsSettings(), this.channel, this.executor);
- this.deleteSubscriptionCallable =
- ApiCallable.create(settings.deleteSubscriptionSettings(), this.channel, this.executor);
- this.modifyAckDeadlineCallable =
- ApiCallable.create(settings.modifyAckDeadlineSettings(), this.channel, this.executor);
- this.acknowledgeCallable =
- ApiCallable.create(settings.acknowledgeSettings(), this.channel, this.executor);
- this.pullCallable = ApiCallable.create(settings.pullSettings(), this.channel, this.executor);
- this.modifyPushConfigCallable =
- ApiCallable.create(settings.modifyPushConfigSettings(), this.channel, this.executor);
-
- if (settings.getChannelProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- channel.shutdown();
- }
- });
- }
- if (settings.getExecutorProvider().shouldAutoClose()) {
- closeables.add(
- new Closeable() {
- @Override
- public void close() throws IOException {
- executor.shutdown();
- }
- });
- }
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a subscription to a given topic for a given subscriber.
- * If the subscription already exists, returns `ALREADY_EXISTS`.
- * If the corresponding topic doesn't exist, returns `NOT_FOUND`.
- *
- * If the name is not provided in the request, the server will assign a random
- * name for this subscription on the same project as the topic.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedName = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * String formattedTopic = SubscriberApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * PushConfig pushConfig = PushConfig.newBuilder().build();
- * int ackDeadlineSeconds = 0;
- * Subscription response = subscriberApi.createSubscription(formattedName, formattedTopic, pushConfig, ackDeadlineSeconds);
- * }
- *
- *
- * @param name The name of the subscription. It must have the format
- * `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
- * start with a letter, and contain only letters (`[A-Za-z]`), numbers
- * (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
- * plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
- * in length, and it must not start with `"goog"`.
- * @param topic The name of the topic from which this subscription is receiving messages.
- * The value of this field will be `_deleted-topic_` if the topic has been
- * deleted.
- * @param pushConfig If push delivery is used with this subscription, this field is
- * used to configure it. An empty `pushConfig` signifies that the subscriber
- * will pull and ack messages using API methods.
- * @param ackDeadlineSeconds This value is the maximum time after a subscriber receives a message
- * before the subscriber should acknowledge the message. After message
- * delivery but before the ack deadline expires and before the message is
- * acknowledged, it is an outstanding message and will not be delivered
- * again during that time (on a best-effort basis).
- *
- * For pull subscriptions, this value is used as the initial value for the ack
- * deadline. To override this value for a given message, call
- * `ModifyAckDeadline` with the corresponding `ack_id` if using
- * pull.
- *
- * For push delivery, this value is also used to set the request timeout for
- * the call to the push endpoint.
- *
- * If the subscriber never acknowledges the message, the Pub/Sub
- * system will eventually redeliver the message.
- *
- * If this parameter is not set, the default value of 10 seconds is used.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final Subscription createSubscription(
- String name, String topic, PushConfig pushConfig, int ackDeadlineSeconds) {
- SUBSCRIPTION_PATH_TEMPLATE.validate(name, "createSubscription");
- TOPIC_PATH_TEMPLATE.validate(topic, "createSubscription");
- Subscription request =
- Subscription.newBuilder()
- .setName(name)
- .setTopic(topic)
- .setPushConfig(pushConfig)
- .setAckDeadlineSeconds(ackDeadlineSeconds)
- .build();
- return createSubscription(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a subscription to a given topic for a given subscriber.
- * If the subscription already exists, returns `ALREADY_EXISTS`.
- * If the corresponding topic doesn't exist, returns `NOT_FOUND`.
- *
- * If the name is not provided in the request, the server will assign a random
- * name for this subscription on the same project as the topic.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedName = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * String formattedTopic = SubscriberApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * Subscription request = Subscription.newBuilder()
- * .setName(formattedName)
- * .setTopic(formattedTopic)
- * .build();
- * Subscription response = subscriberApi.createSubscription(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final Subscription createSubscription(Subscription request) {
- return createSubscriptionCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Creates a subscription to a given topic for a given subscriber.
- * If the subscription already exists, returns `ALREADY_EXISTS`.
- * If the corresponding topic doesn't exist, returns `NOT_FOUND`.
- *
- * If the name is not provided in the request, the server will assign a random
- * name for this subscription on the same project as the topic.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedName = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * String formattedTopic = SubscriberApi.formatTopicName("[PROJECT]", "[TOPIC]");
- * Subscription request = Subscription.newBuilder()
- * .setName(formattedName)
- * .setTopic(formattedTopic)
- * .build();
- * ListenableFuture<Subscription> future = subscriberApi.createSubscriptionCallable().futureCall(request);
- * // Do something
- * Subscription response = future.get();
- * }
- *
- */
- public final ApiCallable createSubscriptionCallable() {
- return createSubscriptionCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets the configuration details of a subscription.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * Subscription response = subscriberApi.getSubscription(formattedSubscription);
- * }
- *
- *
- * @param subscription The name of the subscription to get.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final Subscription getSubscription(String subscription) {
- SUBSCRIPTION_PATH_TEMPLATE.validate(subscription, "getSubscription");
- GetSubscriptionRequest request =
- GetSubscriptionRequest.newBuilder().setSubscription(subscription).build();
- return getSubscription(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets the configuration details of a subscription.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * GetSubscriptionRequest request = GetSubscriptionRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .build();
- * Subscription response = subscriberApi.getSubscription(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final Subscription getSubscription(GetSubscriptionRequest request) {
- return getSubscriptionCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Gets the configuration details of a subscription.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * GetSubscriptionRequest request = GetSubscriptionRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .build();
- * ListenableFuture<Subscription> future = subscriberApi.getSubscriptionCallable().futureCall(request);
- * // Do something
- * Subscription response = future.get();
- * }
- *
- */
- public final ApiCallable getSubscriptionCallable() {
- return getSubscriptionCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists matching subscriptions.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedProject = SubscriberApi.formatProjectName("[PROJECT]");
- * for (Subscription element : subscriberApi.listSubscriptions(formattedProject)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param project The name of the cloud project that subscriptions belong to.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listSubscriptions(String project) {
- PROJECT_PATH_TEMPLATE.validate(project, "listSubscriptions");
- ListSubscriptionsRequest request =
- ListSubscriptionsRequest.newBuilder().setProject(project).build();
- return listSubscriptions(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists matching subscriptions.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedProject = SubscriberApi.formatProjectName("[PROJECT]");
- * ListSubscriptionsRequest request = ListSubscriptionsRequest.newBuilder()
- * .setProject(formattedProject)
- * .build();
- * for (Subscription element : subscriberApi.listSubscriptions(request)) {
- * // doThingsWith(element);
- * }
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PageAccessor listSubscriptions(ListSubscriptionsRequest request) {
- return listSubscriptionsPagedCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists matching subscriptions.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedProject = SubscriberApi.formatProjectName("[PROJECT]");
- * ListSubscriptionsRequest request = ListSubscriptionsRequest.newBuilder()
- * .setProject(formattedProject)
- * .build();
- * ListenableFuture<PageAccessor<Subscription>> future = subscriberApi.listSubscriptionsPagedCallable().futureCall(request);
- * // Do something
- * for (Subscription element : future.get()) {
- * // doThingsWith(element);
- * }
- * }
- *
- */
- public final ApiCallable>
- listSubscriptionsPagedCallable() {
- return listSubscriptionsPagedCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Lists matching subscriptions.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedProject = SubscriberApi.formatProjectName("[PROJECT]");
- * ListSubscriptionsRequest request = ListSubscriptionsRequest.newBuilder()
- * .setProject(formattedProject)
- * .build();
- * while (true) {
- * ListSubscriptionsResponse response = subscriberApi.listSubscriptionsCallable().call(request);
- * for (Subscription element : response.getSubscriptionsList()) {
- * // doThingsWith(element);
- * }
- * String nextPageToken = response.getNextPageToken();
- * if (!Strings.isNullOrEmpty(nextPageToken)) {
- * request = request.toBuilder().setPageToken(nextPageToken).build();
- * } else {
- * break;
- * }
- * }
- * }
- *
- */
- public final ApiCallable
- listSubscriptionsCallable() {
- return listSubscriptionsCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes an existing subscription. All pending messages in the subscription
- * are immediately dropped. Calls to `Pull` after deletion will return
- * `NOT_FOUND`. After a subscription is deleted, a new one may be created with
- * the same name, but the new one has no association with the old
- * subscription, or its topic unless the same topic is specified.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * subscriberApi.deleteSubscription(formattedSubscription);
- * }
- *
- *
- * @param subscription The subscription to delete.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void deleteSubscription(String subscription) {
- SUBSCRIPTION_PATH_TEMPLATE.validate(subscription, "deleteSubscription");
- DeleteSubscriptionRequest request =
- DeleteSubscriptionRequest.newBuilder().setSubscription(subscription).build();
- deleteSubscription(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes an existing subscription. All pending messages in the subscription
- * are immediately dropped. Calls to `Pull` after deletion will return
- * `NOT_FOUND`. After a subscription is deleted, a new one may be created with
- * the same name, but the new one has no association with the old
- * subscription, or its topic unless the same topic is specified.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * DeleteSubscriptionRequest request = DeleteSubscriptionRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .build();
- * subscriberApi.deleteSubscription(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- private final void deleteSubscription(DeleteSubscriptionRequest request) {
- deleteSubscriptionCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Deletes an existing subscription. All pending messages in the subscription
- * are immediately dropped. Calls to `Pull` after deletion will return
- * `NOT_FOUND`. After a subscription is deleted, a new one may be created with
- * the same name, but the new one has no association with the old
- * subscription, or its topic unless the same topic is specified.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * DeleteSubscriptionRequest request = DeleteSubscriptionRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .build();
- * ListenableFuture<Void> future = subscriberApi.deleteSubscriptionCallable().futureCall(request);
- * // Do something
- * future.get();
- * }
- *
- */
- public final ApiCallable deleteSubscriptionCallable() {
- return deleteSubscriptionCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Modifies the ack deadline for a specific message. This method is useful
- * to indicate that more time is needed to process a message by the
- * subscriber, or to make the message available for redelivery if the
- * processing was interrupted.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * List<String> ackIds = new ArrayList<>();
- * int ackDeadlineSeconds = 0;
- * subscriberApi.modifyAckDeadline(formattedSubscription, ackIds, ackDeadlineSeconds);
- * }
- *
- *
- * @param subscription The name of the subscription.
- * @param ackIds List of acknowledgment IDs.
- * @param ackDeadlineSeconds The new ack deadline with respect to the time this request was sent to
- * the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new
- * ack deadline will expire 10 seconds after the `ModifyAckDeadline` call
- * was made. Specifying zero may immediately make the message available for
- * another pull request.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void modifyAckDeadline(
- String subscription, List ackIds, int ackDeadlineSeconds) {
- SUBSCRIPTION_PATH_TEMPLATE.validate(subscription, "modifyAckDeadline");
- ModifyAckDeadlineRequest request =
- ModifyAckDeadlineRequest.newBuilder()
- .setSubscription(subscription)
- .addAllAckIds(ackIds)
- .setAckDeadlineSeconds(ackDeadlineSeconds)
- .build();
- modifyAckDeadline(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Modifies the ack deadline for a specific message. This method is useful
- * to indicate that more time is needed to process a message by the
- * subscriber, or to make the message available for redelivery if the
- * processing was interrupted.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * List<String> ackIds = new ArrayList<>();
- * int ackDeadlineSeconds = 0;
- * ModifyAckDeadlineRequest request = ModifyAckDeadlineRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .addAllAckIds(ackIds)
- * .setAckDeadlineSeconds(ackDeadlineSeconds)
- * .build();
- * subscriberApi.modifyAckDeadline(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void modifyAckDeadline(ModifyAckDeadlineRequest request) {
- modifyAckDeadlineCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Modifies the ack deadline for a specific message. This method is useful
- * to indicate that more time is needed to process a message by the
- * subscriber, or to make the message available for redelivery if the
- * processing was interrupted.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * List<String> ackIds = new ArrayList<>();
- * int ackDeadlineSeconds = 0;
- * ModifyAckDeadlineRequest request = ModifyAckDeadlineRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .addAllAckIds(ackIds)
- * .setAckDeadlineSeconds(ackDeadlineSeconds)
- * .build();
- * ListenableFuture<Void> future = subscriberApi.modifyAckDeadlineCallable().futureCall(request);
- * // Do something
- * future.get();
- * }
- *
- */
- public final ApiCallable modifyAckDeadlineCallable() {
- return modifyAckDeadlineCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Acknowledges the messages associated with the `ack_ids` in the
- * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
- * from the subscription.
- *
- * Acknowledging a message whose ack deadline has expired may succeed,
- * but such a message may be redelivered later. Acknowledging a message more
- * than once will not result in an error.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * List<String> ackIds = new ArrayList<>();
- * subscriberApi.acknowledge(formattedSubscription, ackIds);
- * }
- *
- *
- * @param subscription The subscription whose message is being acknowledged.
- * @param ackIds The acknowledgment ID for the messages being acknowledged that was returned
- * by the Pub/Sub system in the `Pull` response. Must not be empty.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void acknowledge(String subscription, List ackIds) {
- SUBSCRIPTION_PATH_TEMPLATE.validate(subscription, "acknowledge");
- AcknowledgeRequest request =
- AcknowledgeRequest.newBuilder().setSubscription(subscription).addAllAckIds(ackIds).build();
- acknowledge(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Acknowledges the messages associated with the `ack_ids` in the
- * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
- * from the subscription.
- *
- * Acknowledging a message whose ack deadline has expired may succeed,
- * but such a message may be redelivered later. Acknowledging a message more
- * than once will not result in an error.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * List<String> ackIds = new ArrayList<>();
- * AcknowledgeRequest request = AcknowledgeRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .addAllAckIds(ackIds)
- * .build();
- * subscriberApi.acknowledge(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void acknowledge(AcknowledgeRequest request) {
- acknowledgeCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Acknowledges the messages associated with the `ack_ids` in the
- * `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
- * from the subscription.
- *
- * Acknowledging a message whose ack deadline has expired may succeed,
- * but such a message may be redelivered later. Acknowledging a message more
- * than once will not result in an error.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * List<String> ackIds = new ArrayList<>();
- * AcknowledgeRequest request = AcknowledgeRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .addAllAckIds(ackIds)
- * .build();
- * ListenableFuture<Void> future = subscriberApi.acknowledgeCallable().futureCall(request);
- * // Do something
- * future.get();
- * }
- *
- */
- public final ApiCallable acknowledgeCallable() {
- return acknowledgeCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Pulls messages from the server. Returns an empty list if there are no
- * messages available in the backlog. The server may return `UNAVAILABLE` if
- * there are too many concurrent pull requests pending for the given
- * subscription.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * boolean returnImmediately = false;
- * int maxMessages = 0;
- * PullResponse response = subscriberApi.pull(formattedSubscription, returnImmediately, maxMessages);
- * }
- *
- *
- * @param subscription The subscription from which messages should be pulled.
- * @param returnImmediately If this is specified as true the system will respond immediately even if
- * it is not able to return a message in the `Pull` response. Otherwise the
- * system is allowed to wait until at least one message is available rather
- * than returning no messages. The client may cancel the request if it does
- * not wish to wait any longer for the response.
- * @param maxMessages The maximum number of messages returned for this request. The Pub/Sub
- * system may return fewer than the number specified.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PullResponse pull(String subscription, boolean returnImmediately, int maxMessages) {
- SUBSCRIPTION_PATH_TEMPLATE.validate(subscription, "pull");
- PullRequest request =
- PullRequest.newBuilder()
- .setSubscription(subscription)
- .setReturnImmediately(returnImmediately)
- .setMaxMessages(maxMessages)
- .build();
- return pull(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Pulls messages from the server. Returns an empty list if there are no
- * messages available in the backlog. The server may return `UNAVAILABLE` if
- * there are too many concurrent pull requests pending for the given
- * subscription.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * int maxMessages = 0;
- * PullRequest request = PullRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .setMaxMessages(maxMessages)
- * .build();
- * PullResponse response = subscriberApi.pull(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final PullResponse pull(PullRequest request) {
- return pullCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Pulls messages from the server. Returns an empty list if there are no
- * messages available in the backlog. The server may return `UNAVAILABLE` if
- * there are too many concurrent pull requests pending for the given
- * subscription.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * int maxMessages = 0;
- * PullRequest request = PullRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .setMaxMessages(maxMessages)
- * .build();
- * ListenableFuture<PullResponse> future = subscriberApi.pullCallable().futureCall(request);
- * // Do something
- * PullResponse response = future.get();
- * }
- *
- */
- public final ApiCallable pullCallable() {
- return pullCallable;
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Modifies the `PushConfig` for a specified subscription.
- *
- * This may be used to change a push subscription to a pull one (signified by
- * an empty `PushConfig`) or vice versa, or change the endpoint URL and other
- * attributes of a push subscription. Messages will accumulate for delivery
- * continuously through the call regardless of changes to the `PushConfig`.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * PushConfig pushConfig = PushConfig.newBuilder().build();
- * subscriberApi.modifyPushConfig(formattedSubscription, pushConfig);
- * }
- *
- *
- * @param subscription The name of the subscription.
- * @param pushConfig The push configuration for future deliveries.
- *
- * An empty `pushConfig` indicates that the Pub/Sub system should
- * stop pushing messages from the given subscription and allow
- * messages to be pulled and acknowledged - effectively pausing
- * the subscription if `Pull` is not called.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void modifyPushConfig(String subscription, PushConfig pushConfig) {
- SUBSCRIPTION_PATH_TEMPLATE.validate(subscription, "modifyPushConfig");
- ModifyPushConfigRequest request =
- ModifyPushConfigRequest.newBuilder()
- .setSubscription(subscription)
- .setPushConfig(pushConfig)
- .build();
- modifyPushConfig(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Modifies the `PushConfig` for a specified subscription.
- *
- * This may be used to change a push subscription to a pull one (signified by
- * an empty `PushConfig`) or vice versa, or change the endpoint URL and other
- * attributes of a push subscription. Messages will accumulate for delivery
- * continuously through the call regardless of changes to the `PushConfig`.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * PushConfig pushConfig = PushConfig.newBuilder().build();
- * ModifyPushConfigRequest request = ModifyPushConfigRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .setPushConfig(pushConfig)
- * .build();
- * subscriberApi.modifyPushConfig(request);
- * }
- *
- *
- * @param request The request object containing all of the parameters for the API call.
- * @throws com.google.api.gax.grpc.ApiException if the remote call fails
- */
- public final void modifyPushConfig(ModifyPushConfigRequest request) {
- modifyPushConfigCallable().call(request);
- }
-
- // AUTO-GENERATED DOCUMENTATION AND METHOD
- /**
- * Modifies the `PushConfig` for a specified subscription.
- *
- * This may be used to change a push subscription to a pull one (signified by
- * an empty `PushConfig`) or vice versa, or change the endpoint URL and other
- * attributes of a push subscription. Messages will accumulate for delivery
- * continuously through the call regardless of changes to the `PushConfig`.
- *
- * Sample code:
- *
- * try (SubscriberApi subscriberApi = SubscriberApi.create()) {
- * String formattedSubscription = SubscriberApi.formatSubscriptionName("[PROJECT]", "[SUBSCRIPTION]");
- * PushConfig pushConfig = PushConfig.newBuilder().build();
- * ModifyPushConfigRequest request = ModifyPushConfigRequest.newBuilder()
- * .setSubscription(formattedSubscription)
- * .setPushConfig(pushConfig)
- * .build();
- * ListenableFuture<Void> future = subscriberApi.modifyPushConfigCallable().futureCall(request);
- * // Do something
- * future.get();
- * }
- *
- */
- public final ApiCallable modifyPushConfigCallable() {
- return modifyPushConfigCallable;
- }
-
- /**
- * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
- * cancelled.
- */
- @Override
- public final void close() throws Exception {
- for (AutoCloseable closeable : closeables) {
- closeable.close();
- }
- }
-}
diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberSettings.java
deleted file mode 100644
index 1804008a6474..000000000000
--- a/gcloud-java-pubsub/baseline/src/main/java/com/google/cloud/pubsub/spi/v1/SubscriberSettings.java
+++ /dev/null
@@ -1,554 +0,0 @@
-/*
- * Copyright 2016 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.pubsub.spi.v1;
-
-import com.google.api.gax.core.ConnectionSettings;
-import com.google.api.gax.core.RetrySettings;
-import com.google.api.gax.grpc.ApiCallSettings;
-import com.google.api.gax.grpc.PageStreamingCallSettings;
-import com.google.api.gax.grpc.PageStreamingDescriptor;
-import com.google.api.gax.grpc.ServiceApiSettings;
-import com.google.api.gax.grpc.SimpleCallSettings;
-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.protobuf.Empty;
-import com.google.pubsub.v1.AcknowledgeRequest;
-import com.google.pubsub.v1.DeleteSubscriptionRequest;
-import com.google.pubsub.v1.GetSubscriptionRequest;
-import com.google.pubsub.v1.ListSubscriptionsRequest;
-import com.google.pubsub.v1.ListSubscriptionsResponse;
-import com.google.pubsub.v1.ModifyAckDeadlineRequest;
-import com.google.pubsub.v1.ModifyPushConfigRequest;
-import com.google.pubsub.v1.PullRequest;
-import com.google.pubsub.v1.PullResponse;
-import com.google.pubsub.v1.SubscriberGrpc;
-import com.google.pubsub.v1.Subscription;
-import io.grpc.ManagedChannel;
-import io.grpc.Status;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.ScheduledExecutorService;
-import org.joda.time.Duration;
-
-// AUTO-GENERATED DOCUMENTATION AND CLASS
-/**
- * Settings class to configure an instance of {@link SubscriberApi}.
- *
- * The default instance has everything set to sensible defaults:
- *
- *
- * - The default service address (pubsub.googleapis.com) and default port (443)
- * 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 createSubscription to 30 seconds:
- *
- *
- *
- * SubscriberSettings.Builder subscriberSettingsBuilder =
- * SubscriberSettings.defaultBuilder();
- * subscriberSettingsBuilder.createSubscriptionSettings().getRetrySettingsBuilder()
- * .setTotalTimeout(Duration.standardSeconds(30));
- * SubscriberSettings subscriberSettings = subscriberSettingsBuilder.build();
- *
- *
- */
-@javax.annotation.Generated("by GAPIC")
-public class SubscriberSettings extends ServiceApiSettings {
- /**
- * The default address of the service.
- */
- private static final String DEFAULT_SERVICE_ADDRESS = "pubsub.googleapis.com";
-
- /**
- * The default port of the service.
- */
- private static final int DEFAULT_SERVICE_PORT = 443;
-
- /**
- * 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/pubsub")
- .build();
-
- /**
- * The default connection settings of the service.
- */
- public static final ConnectionSettings DEFAULT_CONNECTION_SETTINGS =
- ConnectionSettings.newBuilder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build();
-
- private final SimpleCallSettings createSubscriptionSettings;
- private final SimpleCallSettings getSubscriptionSettings;
- private final PageStreamingCallSettings<
- ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription>
- listSubscriptionsSettings;
- private final SimpleCallSettings deleteSubscriptionSettings;
- private final SimpleCallSettings modifyAckDeadlineSettings;
- private final SimpleCallSettings acknowledgeSettings;
- private final SimpleCallSettings pullSettings;
- private final SimpleCallSettings modifyPushConfigSettings;
-
- /**
- * Returns the object with the settings used for calls to createSubscription.
- */
- public SimpleCallSettings createSubscriptionSettings() {
- return createSubscriptionSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to getSubscription.
- */
- public SimpleCallSettings getSubscriptionSettings() {
- return getSubscriptionSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to listSubscriptions.
- */
- public PageStreamingCallSettings<
- ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription>
- listSubscriptionsSettings() {
- return listSubscriptionsSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to deleteSubscription.
- */
- public SimpleCallSettings deleteSubscriptionSettings() {
- return deleteSubscriptionSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to modifyAckDeadline.
- */
- public SimpleCallSettings modifyAckDeadlineSettings() {
- return modifyAckDeadlineSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to acknowledge.
- */
- public SimpleCallSettings acknowledgeSettings() {
- return acknowledgeSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to pull.
- */
- public SimpleCallSettings pullSettings() {
- return pullSettings;
- }
-
- /**
- * Returns the object with the settings used for calls to modifyPushConfig.
- */
- public SimpleCallSettings modifyPushConfigSettings() {
- return modifyPushConfigSettings;
- }
-
- /**
- * Returns the default service address.
- */
- public static String getDefaultServiceAddress() {
- return DEFAULT_SERVICE_ADDRESS;
- }
-
- /**
- * Returns the default service port.
- */
- public static int getDefaultServicePort() {
- return DEFAULT_SERVICE_PORT;
- }
-
- /**
- * Returns the default service scopes.
- */
- public static ImmutableList getDefaultServiceScopes() {
- return DEFAULT_SERVICE_SCOPES;
- }
-
- /**
- * Returns a builder for this class with recommended defaults.
- */
- public static Builder defaultBuilder() {
- return Builder.createDefault();
- }
-
- /**
- * Returns a new builder for this class.
- */
- public static Builder newBuilder() {
- return new Builder();
- }
-
- /**
- * Returns a builder containing all the values of this settings class.
- */
- public Builder toBuilder() {
- return new Builder(this);
- }
-
- private SubscriberSettings(Builder settingsBuilder) throws IOException {
- super(
- settingsBuilder.getChannelProvider(),
- settingsBuilder.getExecutorProvider(),
- settingsBuilder.getGeneratorName(),
- settingsBuilder.getGeneratorVersion(),
- settingsBuilder.getClientLibName(),
- settingsBuilder.getClientLibVersion());
-
- createSubscriptionSettings = settingsBuilder.createSubscriptionSettings().build();
- getSubscriptionSettings = settingsBuilder.getSubscriptionSettings().build();
- listSubscriptionsSettings = settingsBuilder.listSubscriptionsSettings().build();
- deleteSubscriptionSettings = settingsBuilder.deleteSubscriptionSettings().build();
- modifyAckDeadlineSettings = settingsBuilder.modifyAckDeadlineSettings().build();
- acknowledgeSettings = settingsBuilder.acknowledgeSettings().build();
- pullSettings = settingsBuilder.pullSettings().build();
- modifyPushConfigSettings = settingsBuilder.modifyPushConfigSettings().build();
- }
-
- private static PageStreamingDescriptor<
- ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription>
- LIST_SUBSCRIPTIONS_PAGE_STR_DESC =
- new PageStreamingDescriptor<
- ListSubscriptionsRequest, ListSubscriptionsResponse, Subscription>() {
- @Override
- public Object emptyToken() {
- return "";
- }
-
- @Override
- public ListSubscriptionsRequest injectToken(
- ListSubscriptionsRequest payload, Object token) {
- return ListSubscriptionsRequest.newBuilder(payload)
- .setPageToken((String) token)
- .build();
- }
-
- @Override
- public Object extractNextToken(ListSubscriptionsResponse payload) {
- return payload.getNextPageToken();
- }
-
- @Override
- public Iterable