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:
+ *
+ *
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:
+ *
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listSinks(ListSinksRequest request) {
- return listSinksIterableCallable().call(request);
+ public final PageAccessor listSinks(ListSinksRequest request) {
+ return listSinksPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists sinks.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
- public final ApiCallable> listSinksIterableCallable() {
- return listSinksIterableCallable;
+ public final ApiCallable> listSinksPagedCallable() {
+ return listSinksPagedCallable;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists sinks.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -300,12 +471,13 @@ public final ApiCallable getSinkCallable() {
* The new sink must be provided in the request.
* @param sink The new sink, which must not have an identifier that already
* exists.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final LogSink createSink(String projectName, LogSink sink) {
+ PROJECT_PATH_TEMPLATE.validate(projectName);
+
CreateSinkRequest request =
CreateSinkRequest.newBuilder().setProjectName(projectName).setSink(sink).build();
-
return createSink(request);
}
@@ -313,11 +485,24 @@ public final LogSink createSink(String projectName, LogSink sink) {
/**
* Creates a sink.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public LogSink createSink(CreateSinkRequest request) {
return createSinkCallable().call(request);
@@ -327,9 +512,23 @@ public LogSink createSink(CreateSinkRequest request) {
/**
* Creates a sink.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -353,12 +561,13 @@ public final ApiCallable createSinkCallable() {
* @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 ApiException if the remote call fails
+ * @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);
+
UpdateSinkRequest request =
UpdateSinkRequest.newBuilder().setSinkName(sinkName).setSink(sink).build();
-
return updateSink(request);
}
@@ -366,11 +575,24 @@ public final LogSink updateSink(String sinkName, LogSink sink) {
/**
* Creates or updates a sink.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public LogSink updateSink(UpdateSinkRequest request) {
return updateSinkCallable().call(request);
@@ -380,9 +602,23 @@ public LogSink updateSink(UpdateSinkRequest request) {
/**
* Creates or updates a sink.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable deleteSinkCallable() {
return deleteSinkCallable;
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
index 157f4b5d2427..9c1558fec565 100644
--- 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
@@ -40,6 +40,7 @@
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;
@@ -57,12 +58,39 @@
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;
// Manually-added imports: add custom (non-generated) imports after this point.
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
+/**
+ * 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 ListSinks to 30 seconds:
+ *
+ *
+ */
@javax.annotation.Generated("by GAPIC")
public class ConfigServiceV2Settings extends ServiceApiSettings {
@@ -94,6 +122,16 @@ public class ConfigServiceV2Settings extends ServiceApiSettings {
.add("https://www.googleapis.com/auth/cloud-platform")
.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;
@@ -102,45 +140,67 @@ public class ConfigServiceV2Settings extends ServiceApiSettings {
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;
}
- public static ConfigServiceV2Settings defaultInstance() throws IOException {
- return newBuilder().build();
+ /**
+ * 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.getOrBuildChannel(),
- settingsBuilder.shouldAutoCloseChannel(),
- settingsBuilder.getOrBuildExecutor(),
- settingsBuilder.getConnectionSettings(),
+ settingsBuilder.getChannelProvider(),
+ settingsBuilder.getExecutorProvider(),
settingsBuilder.getGeneratorName(),
settingsBuilder.getGeneratorVersion(),
settingsBuilder.getClientLibName(),
@@ -177,6 +237,9 @@ public Iterable extractResources(ListSinksResponse payload) {
}
};
+ /**
+ * Builder for ConfigServiceV2Settings.
+ */
public static class Builder extends ServiceApiSettings.Builder {
private final ImmutableList methodSettingsBuilders;
@@ -219,38 +282,19 @@ public static class Builder extends ServiceApiSettings.Builder {
}
private Builder() {
- super(
- ConnectionSettings.builder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build());
+ super(DEFAULT_CONNECTION_SETTINGS);
listSinksSettings =
PageStreamingCallSettings.newBuilder(
- ConfigServiceV2Grpc.METHOD_LIST_SINKS, LIST_SINKS_PAGE_STR_DESC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- getSinkSettings =
- SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_GET_SINK)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- createSinkSettings =
- SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_CREATE_SINK)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- updateSinkSettings =
- SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_UPDATE_SINK)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- deleteSinkSettings =
- SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_DELETE_SINK)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ 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(
@@ -261,6 +305,36 @@ private Builder() {
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);
@@ -279,6 +353,17 @@ private Builder(ConfigServiceV2Settings settings) {
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);
@@ -292,8 +377,14 @@ public Builder provideChannelWith(ConnectionSettings settings) {
}
@Override
- public Builder setExecutor(ScheduledExecutorService executor) {
- super.setExecutor(executor);
+ public Builder provideChannelWith(Credentials credentials) {
+ super.provideChannelWith(credentials);
+ return this;
+ }
+
+ @Override
+ public Builder provideChannelWith(List scopes) {
+ super.provideChannelWith(scopes);
return this;
}
@@ -309,28 +400,48 @@ public Builder setClientLibHeader(String name, String 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;
}
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
index ead7c1b886aa..70960a025987 100644
--- 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
@@ -35,6 +35,7 @@
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;
@@ -52,6 +53,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ScheduledExecutorService;
// Manually-added imports: add custom (non-generated) imports after this point.
@@ -59,32 +61,86 @@
/**
* 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:
+ *
+ *
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:
+ *
+ *
+ *
*
*
*
* @param logName Required. The resource name of the log to delete. Example:
* `"projects/my-project/logs/syslog"`.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final void deleteLog(String logName) {
+ LOG_PATH_TEMPLATE.validate(logName);
DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(logName).build();
-
deleteLog(request);
}
@@ -221,11 +302,22 @@ public final void deleteLog(String logName) {
* Deletes a log and all its log entries.
* The log will reappear if it receives new entries.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
private void deleteLog(DeleteLogRequest request) {
deleteLogCallable().call(request);
@@ -236,9 +328,21 @@ private void deleteLog(DeleteLogRequest request) {
* Deletes a log and all its log entries.
* The log will reappear if it receives new entries.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable deleteLogCallable() {
return deleteLogCallable;
@@ -251,6 +355,17 @@ public final ApiCallable deleteLogCallable() {
* Writes log entries to Cloud Logging.
* All log entries in Cloud Logging are written by this method.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -266,13 +381,15 @@ public final ApiCallable deleteLogCallable() {
* Example: `{ "size": "large", "color":"red" }`
* @param entries Required. The log entries to write. The log entries must have values for
* all required fields.
- * @throws ApiException if the remote call fails
+ * @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);
+
WriteLogEntriesRequest request =
WriteLogEntriesRequest.newBuilder()
.setLogName(logName)
@@ -280,7 +397,6 @@ public final WriteLogEntriesResponse writeLogEntries(
.putAllLabels(labels)
.addAllEntries(entries)
.build();
-
return writeLogEntries(request);
}
@@ -289,11 +405,22 @@ public final WriteLogEntriesResponse writeLogEntries(
* Writes log entries to Cloud Logging.
* All log entries in Cloud Logging are written by this method.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest request) {
return writeLogEntriesCallable().call(request);
@@ -304,9 +431,21 @@ public WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest request) {
* Writes log entries to Cloud Logging.
* All log entries in Cloud Logging are written by this method.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -336,10 +487,11 @@ public WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest request) {
* `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 ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listLogEntries(
+ public final PageAccessor listLogEntries(
List projectIds, String filter, String orderBy) {
+
ListLogEntriesRequest request =
ListLogEntriesRequest.newBuilder()
.addAllProjectIds(projectIds)
@@ -355,14 +507,27 @@ public final Iterable listLogEntries(
* Logging. For ways to export log entries, see
* [Exporting Logs](/logging/docs/export).
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listLogEntries(ListLogEntriesRequest request) {
- return listLogEntriesIterableCallable().call(request);
+ public final PageAccessor listLogEntries(ListLogEntriesRequest request) {
+ return listLogEntriesPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
@@ -371,13 +536,27 @@ public final Iterable listLogEntries(ListLogEntriesRequest request) {
* Logging. For ways to export log entries, see
* [Exporting Logs](/logging/docs/export).
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
- public final ApiCallable>
- listLogEntriesIterableCallable() {
- return listLogEntriesIterableCallable;
+ public final ApiCallable>
+ listLogEntriesPagedCallable() {
+ return listLogEntriesPagedCallable;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
@@ -386,9 +565,30 @@ public final Iterable listLogEntries(ListLogEntriesRequest request) {
* Logging. For ways to export log entries, see
* [Exporting Logs](/logging/docs/export).
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable listLogEntriesCallable() {
return listLogEntriesCallable;
@@ -400,38 +600,80 @@ public final ApiCallable listLogE
/**
* Lists monitored resource descriptors that are used by Cloud Logging.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listMonitoredResourceDescriptors(
+ public final PageAccessor listMonitoredResourceDescriptors(
ListMonitoredResourceDescriptorsRequest request) {
- return listMonitoredResourceDescriptorsIterableCallable().call(request);
+ return listMonitoredResourceDescriptorsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists monitored resource descriptors that are used by Cloud Logging.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable<
- ListMonitoredResourceDescriptorsRequest, Iterable>
- listMonitoredResourceDescriptorsIterableCallable() {
- return listMonitoredResourceDescriptorsIterableCallable;
+ ListMonitoredResourceDescriptorsRequest, PageAccessor>
+ listMonitoredResourceDescriptorsPagedCallable() {
+ return listMonitoredResourceDescriptorsPagedCallable;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists monitored resource descriptors that are used by Cloud Logging.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable<
ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>
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
index da6ae99fd9a7..c37e5c4ad305 100644
--- 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
@@ -41,6 +41,7 @@
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;
@@ -59,12 +60,39 @@
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;
// Manually-added imports: add custom (non-generated) imports after this point.
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
+/**
+ * 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:
+ *
+ *
+ */
@javax.annotation.Generated("by GAPIC")
public class LoggingServiceV2Settings extends ServiceApiSettings {
@@ -96,6 +124,16 @@ public class LoggingServiceV2Settings extends ServiceApiSettings {
.add("https://www.googleapis.com/auth/cloud-platform")
.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;
@@ -107,20 +145,32 @@ public class LoggingServiceV2Settings extends ServiceApiSettings {
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>
@@ -128,24 +178,31 @@ public SimpleCallSettings deleteLogSettings() {
return listMonitoredResourceDescriptorsSettings;
}
- public static LoggingServiceV2Settings defaultInstance() throws IOException {
- return newBuilder().build();
+ /**
+ * 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.getOrBuildChannel(),
- settingsBuilder.shouldAutoCloseChannel(),
- settingsBuilder.getOrBuildExecutor(),
- settingsBuilder.getConnectionSettings(),
+ settingsBuilder.getChannelProvider(),
+ settingsBuilder.getExecutorProvider(),
settingsBuilder.getGeneratorName(),
settingsBuilder.getGeneratorVersion(),
settingsBuilder.getClientLibName(),
@@ -214,6 +271,9 @@ public Iterable extractResources(
}
};
+ /**
+ * Builder for LoggingServiceV2Settings.
+ */
public static class Builder extends ServiceApiSettings.Builder {
private final ImmutableList methodSettingsBuilders;
@@ -270,35 +330,21 @@ public static class Builder extends ServiceApiSettings.Builder {
}
private Builder() {
- super(
- ConnectionSettings.builder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build());
-
- deleteLogSettings =
- SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_DELETE_LOG)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ super(DEFAULT_CONNECTION_SETTINGS);
+
+ deleteLogSettings = SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_DELETE_LOG);
writeLogEntriesSettings =
- SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_WRITE_LOG_ENTRIES)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_WRITE_LOG_ENTRIES);
listLogEntriesSettings =
PageStreamingCallSettings.newBuilder(
- LoggingServiceV2Grpc.METHOD_LIST_LOG_ENTRIES, LIST_LOG_ENTRIES_PAGE_STR_DESC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("list"));
+ 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)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ LoggingServiceV2Grpc.METHOD_LIST_MONITORED_RESOURCE_DESCRIPTORS,
+ LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC);
methodSettingsBuilders =
ImmutableList.of(
@@ -308,6 +354,31 @@ private Builder() {
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);
@@ -325,6 +396,17 @@ private Builder(LoggingServiceV2Settings settings) {
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);
@@ -338,8 +420,14 @@ public Builder provideChannelWith(ConnectionSettings settings) {
}
@Override
- public Builder setExecutor(ScheduledExecutorService executor) {
- super.setExecutor(executor);
+ public Builder provideChannelWith(Credentials credentials) {
+ super.provideChannelWith(credentials);
+ return this;
+ }
+
+ @Override
+ public Builder provideChannelWith(List scopes) {
+ super.provideChannelWith(scopes);
return this;
}
@@ -355,26 +443,43 @@ public Builder setClientLibHeader(String name, String 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>
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
index a5f2306577b2..adb4d1c325cd 100644
--- 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
@@ -33,6 +33,7 @@
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;
@@ -48,6 +49,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
// Manually-added imports: add custom (non-generated) imports after this point.
@@ -55,27 +57,81 @@
/**
* Service Description:
*
+ *
This class provides the ability to make remote calls to the backing service through method
+ * calls that map to API methods. Sample code to get started:
+ *
+ *
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:
+ *
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listLogMetrics(ListLogMetricsRequest request) {
- return listLogMetricsIterableCallable().call(request);
+ public final PageAccessor listLogMetrics(ListLogMetricsRequest request) {
+ return listLogMetricsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists logs-based metrics.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
- public final ApiCallable>
- listLogMetricsIterableCallable() {
- return listLogMetricsIterableCallable;
+ public final ApiCallable>
+ listLogMetricsPagedCallable() {
+ return listLogMetricsPagedCallable;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists logs-based metrics.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -304,12 +476,13 @@ public final ApiCallable getLogMetricCallable()
* 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 ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final LogMetric createLogMetric(String projectName, LogMetric metric) {
+ PROJECT_PATH_TEMPLATE.validate(projectName);
+
CreateLogMetricRequest request =
CreateLogMetricRequest.newBuilder().setProjectName(projectName).setMetric(metric).build();
-
return createLogMetric(request);
}
@@ -317,11 +490,24 @@ public final LogMetric createLogMetric(String projectName, LogMetric metric) {
/**
* Creates a logs-based metric.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public LogMetric createLogMetric(CreateLogMetricRequest request) {
return createLogMetricCallable().call(request);
@@ -331,9 +517,23 @@ public LogMetric createLogMetric(CreateLogMetricRequest request) {
/**
* Creates a logs-based metric.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -357,12 +566,13 @@ public final ApiCallable createLogMetricCalla
* @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 ApiException if the remote call fails
+ * @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);
+
UpdateLogMetricRequest request =
UpdateLogMetricRequest.newBuilder().setMetricName(metricName).setMetric(metric).build();
-
return updateLogMetric(request);
}
@@ -370,11 +580,24 @@ public final LogMetric updateLogMetric(String metricName, LogMetric metric) {
/**
* Creates or updates a logs-based metric.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public LogMetric updateLogMetric(UpdateLogMetricRequest request) {
return updateLogMetricCallable().call(request);
@@ -384,9 +607,23 @@ public LogMetric updateLogMetric(UpdateLogMetricRequest request) {
/**
* Creates or updates a logs-based metric.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable deleteLogMetricCallable() {
return deleteLogMetricCallable;
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
index 316a9851bf11..1308b95eb029 100644
--- 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
@@ -40,6 +40,7 @@
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;
@@ -57,12 +58,39 @@
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;
// Manually-added imports: add custom (non-generated) imports after this point.
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
+/**
+ * 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 ListLogMetrics to 30 seconds:
+ *
+ *
+ */
@javax.annotation.Generated("by GAPIC")
public class MetricsServiceV2Settings extends ServiceApiSettings {
@@ -94,6 +122,16 @@ public class MetricsServiceV2Settings extends ServiceApiSettings {
.add("https://www.googleapis.com/auth/cloud-platform")
.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;
@@ -102,45 +140,67 @@ public class MetricsServiceV2Settings extends ServiceApiSettings {
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;
}
- public static MetricsServiceV2Settings defaultInstance() throws IOException {
- return newBuilder().build();
+ /**
+ * 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.getOrBuildChannel(),
- settingsBuilder.shouldAutoCloseChannel(),
- settingsBuilder.getOrBuildExecutor(),
- settingsBuilder.getConnectionSettings(),
+ settingsBuilder.getChannelProvider(),
+ settingsBuilder.getExecutorProvider(),
settingsBuilder.getGeneratorName(),
settingsBuilder.getGeneratorVersion(),
settingsBuilder.getClientLibName(),
@@ -177,6 +237,9 @@ public Iterable extractResources(ListLogMetricsResponse payload) {
}
};
+ /**
+ * Builder for MetricsServiceV2Settings.
+ */
public static class Builder extends ServiceApiSettings.Builder {
private final ImmutableList methodSettingsBuilders;
@@ -220,38 +283,23 @@ public static class Builder extends ServiceApiSettings.Builder {
}
private Builder() {
- super(
- ConnectionSettings.builder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build());
+ super(DEFAULT_CONNECTION_SETTINGS);
listLogMetricsSettings =
PageStreamingCallSettings.newBuilder(
- MetricsServiceV2Grpc.METHOD_LIST_LOG_METRICS, LIST_LOG_METRICS_PAGE_STR_DESC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ MetricsServiceV2Grpc.METHOD_LIST_LOG_METRICS, LIST_LOG_METRICS_PAGE_STR_DESC);
getLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_GET_LOG_METRIC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_GET_LOG_METRIC);
createLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_CREATE_LOG_METRIC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_CREATE_LOG_METRIC);
updateLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_UPDATE_LOG_METRIC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_UPDATE_LOG_METRIC);
deleteLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_DELETE_LOG_METRIC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_DELETE_LOG_METRIC);
methodSettingsBuilders =
ImmutableList.of(
@@ -262,6 +310,36 @@ private Builder() {
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);
@@ -280,6 +358,17 @@ private Builder(MetricsServiceV2Settings settings) {
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);
@@ -293,8 +382,14 @@ public Builder provideChannelWith(ConnectionSettings settings) {
}
@Override
- public Builder setExecutor(ScheduledExecutorService executor) {
- super.setExecutor(executor);
+ public Builder provideChannelWith(Credentials credentials) {
+ super.provideChannelWith(credentials);
+ return this;
+ }
+
+ @Override
+ public Builder provideChannelWith(List scopes) {
+ super.provideChannelWith(scopes);
return this;
}
@@ -310,29 +405,49 @@ public Builder setClientLibHeader(String name, String 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;
}
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
new file mode 100644
index 000000000000..81ee3d3fce7e
--- /dev/null
+++ b/gcloud-java-logging/baseline/src/main/java/com/google/cloud/logging/spi/v2/package-info.java
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+/*
+ * EDITING INSTRUCTIONS
+ * This file was automatically generated. For the short term, the process for
+ * refreshing this file will only be runnable by Google engineers.
+ * Manual additions are allowed because the refresh process performs
+ * a 3-way merge in order to preserve those manual additions. In order to not
+ * break the refresh process, additional documentation should be added between
+ * "manual edit" demarcations.
+ *
+ * Other generated files allow additional edits - see the editing instructions
+ * in those files for more details.
+ *
+ * Happy editing!
+ */
+
+/**
+ * A client to Google Cloud Logging API.
+ *
+ * The interfaces provided are listed below, along with a usage sample
+ *
+ * ===================
+ * LoggingServiceV2Api
+ * ===================
+ *
+ * Service Description: Service for ingesting and querying logs.
+ *
+ * Sample for LoggingServiceV2Api:
+ *
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:
+ *
+ *
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:
+ *
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listSinks(ListSinksRequest request) {
- return listSinksIterableCallable().call(request);
+ public final PageAccessor listSinks(ListSinksRequest request) {
+ return listSinksPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists sinks.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
- public final ApiCallable> listSinksIterableCallable() {
- return listSinksIterableCallable;
+ public final ApiCallable> listSinksPagedCallable() {
+ return listSinksPagedCallable;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists sinks.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -300,12 +471,13 @@ public final ApiCallable getSinkCallable() {
* The new sink must be provided in the request.
* @param sink The new sink, which must not have an identifier that already
* exists.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final LogSink createSink(String projectName, LogSink sink) {
+ PROJECT_PATH_TEMPLATE.validate(projectName);
+
CreateSinkRequest request =
CreateSinkRequest.newBuilder().setProjectName(projectName).setSink(sink).build();
-
return createSink(request);
}
@@ -313,11 +485,24 @@ public final LogSink createSink(String projectName, LogSink sink) {
/**
* Creates a sink.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public LogSink createSink(CreateSinkRequest request) {
return createSinkCallable().call(request);
@@ -327,9 +512,23 @@ public LogSink createSink(CreateSinkRequest request) {
/**
* Creates a sink.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -353,12 +561,13 @@ public final ApiCallable createSinkCallable() {
* @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 ApiException if the remote call fails
+ * @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);
+
UpdateSinkRequest request =
UpdateSinkRequest.newBuilder().setSinkName(sinkName).setSink(sink).build();
-
return updateSink(request);
}
@@ -366,11 +575,24 @@ public final LogSink updateSink(String sinkName, LogSink sink) {
/**
* Creates or updates a sink.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public LogSink updateSink(UpdateSinkRequest request) {
return updateSinkCallable().call(request);
@@ -380,9 +602,23 @@ public LogSink updateSink(UpdateSinkRequest request) {
/**
* Creates or updates a sink.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable deleteSinkCallable() {
return deleteSinkCallable;
diff --git a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java
index 157f4b5d2427..9c1558fec565 100644
--- a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java
+++ b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/ConfigServiceV2Settings.java
@@ -40,6 +40,7 @@
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;
@@ -57,12 +58,39 @@
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;
// Manually-added imports: add custom (non-generated) imports after this point.
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
+/**
+ * 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 ListSinks to 30 seconds:
+ *
+ *
+ */
@javax.annotation.Generated("by GAPIC")
public class ConfigServiceV2Settings extends ServiceApiSettings {
@@ -94,6 +122,16 @@ public class ConfigServiceV2Settings extends ServiceApiSettings {
.add("https://www.googleapis.com/auth/cloud-platform")
.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;
@@ -102,45 +140,67 @@ public class ConfigServiceV2Settings extends ServiceApiSettings {
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;
}
- public static ConfigServiceV2Settings defaultInstance() throws IOException {
- return newBuilder().build();
+ /**
+ * 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.getOrBuildChannel(),
- settingsBuilder.shouldAutoCloseChannel(),
- settingsBuilder.getOrBuildExecutor(),
- settingsBuilder.getConnectionSettings(),
+ settingsBuilder.getChannelProvider(),
+ settingsBuilder.getExecutorProvider(),
settingsBuilder.getGeneratorName(),
settingsBuilder.getGeneratorVersion(),
settingsBuilder.getClientLibName(),
@@ -177,6 +237,9 @@ public Iterable extractResources(ListSinksResponse payload) {
}
};
+ /**
+ * Builder for ConfigServiceV2Settings.
+ */
public static class Builder extends ServiceApiSettings.Builder {
private final ImmutableList methodSettingsBuilders;
@@ -219,38 +282,19 @@ public static class Builder extends ServiceApiSettings.Builder {
}
private Builder() {
- super(
- ConnectionSettings.builder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build());
+ super(DEFAULT_CONNECTION_SETTINGS);
listSinksSettings =
PageStreamingCallSettings.newBuilder(
- ConfigServiceV2Grpc.METHOD_LIST_SINKS, LIST_SINKS_PAGE_STR_DESC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- getSinkSettings =
- SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_GET_SINK)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- createSinkSettings =
- SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_CREATE_SINK)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- updateSinkSettings =
- SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_UPDATE_SINK)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
-
- deleteSinkSettings =
- SimpleCallSettings.newBuilder(ConfigServiceV2Grpc.METHOD_DELETE_SINK)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ 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(
@@ -261,6 +305,36 @@ private Builder() {
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);
@@ -279,6 +353,17 @@ private Builder(ConfigServiceV2Settings settings) {
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);
@@ -292,8 +377,14 @@ public Builder provideChannelWith(ConnectionSettings settings) {
}
@Override
- public Builder setExecutor(ScheduledExecutorService executor) {
- super.setExecutor(executor);
+ public Builder provideChannelWith(Credentials credentials) {
+ super.provideChannelWith(credentials);
+ return this;
+ }
+
+ @Override
+ public Builder provideChannelWith(List scopes) {
+ super.provideChannelWith(scopes);
return this;
}
@@ -309,28 +400,48 @@ public Builder setClientLibHeader(String name, String 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;
}
diff --git a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java
index ead7c1b886aa..70960a025987 100644
--- a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java
+++ b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Api.java
@@ -35,6 +35,7 @@
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;
@@ -52,6 +53,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.ScheduledExecutorService;
// Manually-added imports: add custom (non-generated) imports after this point.
@@ -59,32 +61,86 @@
/**
* 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:
+ *
+ *
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:
+ *
+ *
+ *
*
*
*
* @param logName Required. The resource name of the log to delete. Example:
* `"projects/my-project/logs/syslog"`.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final void deleteLog(String logName) {
+ LOG_PATH_TEMPLATE.validate(logName);
DeleteLogRequest request = DeleteLogRequest.newBuilder().setLogName(logName).build();
-
deleteLog(request);
}
@@ -221,11 +302,22 @@ public final void deleteLog(String logName) {
* Deletes a log and all its log entries.
* The log will reappear if it receives new entries.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
private void deleteLog(DeleteLogRequest request) {
deleteLogCallable().call(request);
@@ -236,9 +328,21 @@ private void deleteLog(DeleteLogRequest request) {
* Deletes a log and all its log entries.
* The log will reappear if it receives new entries.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable deleteLogCallable() {
return deleteLogCallable;
@@ -251,6 +355,17 @@ public final ApiCallable deleteLogCallable() {
* Writes log entries to Cloud Logging.
* All log entries in Cloud Logging are written by this method.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -266,13 +381,15 @@ public final ApiCallable deleteLogCallable() {
* Example: `{ "size": "large", "color":"red" }`
* @param entries Required. The log entries to write. The log entries must have values for
* all required fields.
- * @throws ApiException if the remote call fails
+ * @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);
+
WriteLogEntriesRequest request =
WriteLogEntriesRequest.newBuilder()
.setLogName(logName)
@@ -280,7 +397,6 @@ public final WriteLogEntriesResponse writeLogEntries(
.putAllLabels(labels)
.addAllEntries(entries)
.build();
-
return writeLogEntries(request);
}
@@ -289,11 +405,22 @@ public final WriteLogEntriesResponse writeLogEntries(
* Writes log entries to Cloud Logging.
* All log entries in Cloud Logging are written by this method.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest request) {
return writeLogEntriesCallable().call(request);
@@ -304,9 +431,21 @@ public WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest request) {
* Writes log entries to Cloud Logging.
* All log entries in Cloud Logging are written by this method.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -336,10 +487,11 @@ public WriteLogEntriesResponse writeLogEntries(WriteLogEntriesRequest request) {
* `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 ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listLogEntries(
+ public final PageAccessor listLogEntries(
List projectIds, String filter, String orderBy) {
+
ListLogEntriesRequest request =
ListLogEntriesRequest.newBuilder()
.addAllProjectIds(projectIds)
@@ -355,14 +507,27 @@ public final Iterable listLogEntries(
* Logging. For ways to export log entries, see
* [Exporting Logs](/logging/docs/export).
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listLogEntries(ListLogEntriesRequest request) {
- return listLogEntriesIterableCallable().call(request);
+ public final PageAccessor listLogEntries(ListLogEntriesRequest request) {
+ return listLogEntriesPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
@@ -371,13 +536,27 @@ public final Iterable listLogEntries(ListLogEntriesRequest request) {
* Logging. For ways to export log entries, see
* [Exporting Logs](/logging/docs/export).
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
- public final ApiCallable>
- listLogEntriesIterableCallable() {
- return listLogEntriesIterableCallable;
+ public final ApiCallable>
+ listLogEntriesPagedCallable() {
+ return listLogEntriesPagedCallable;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
@@ -386,9 +565,30 @@ public final Iterable listLogEntries(ListLogEntriesRequest request) {
* Logging. For ways to export log entries, see
* [Exporting Logs](/logging/docs/export).
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable listLogEntriesCallable() {
return listLogEntriesCallable;
@@ -400,38 +600,80 @@ public final ApiCallable listLogE
/**
* Lists monitored resource descriptors that are used by Cloud Logging.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listMonitoredResourceDescriptors(
+ public final PageAccessor listMonitoredResourceDescriptors(
ListMonitoredResourceDescriptorsRequest request) {
- return listMonitoredResourceDescriptorsIterableCallable().call(request);
+ return listMonitoredResourceDescriptorsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists monitored resource descriptors that are used by Cloud Logging.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable<
- ListMonitoredResourceDescriptorsRequest, Iterable>
- listMonitoredResourceDescriptorsIterableCallable() {
- return listMonitoredResourceDescriptorsIterableCallable;
+ ListMonitoredResourceDescriptorsRequest, PageAccessor>
+ listMonitoredResourceDescriptorsPagedCallable() {
+ return listMonitoredResourceDescriptorsPagedCallable;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists monitored resource descriptors that are used by Cloud Logging.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable<
ListMonitoredResourceDescriptorsRequest, ListMonitoredResourceDescriptorsResponse>
diff --git a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java
index da6ae99fd9a7..c37e5c4ad305 100644
--- a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java
+++ b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/LoggingServiceV2Settings.java
@@ -41,6 +41,7 @@
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;
@@ -59,12 +60,39 @@
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;
// Manually-added imports: add custom (non-generated) imports after this point.
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
+/**
+ * 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:
+ *
+ *
+ */
@javax.annotation.Generated("by GAPIC")
public class LoggingServiceV2Settings extends ServiceApiSettings {
@@ -96,6 +124,16 @@ public class LoggingServiceV2Settings extends ServiceApiSettings {
.add("https://www.googleapis.com/auth/cloud-platform")
.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;
@@ -107,20 +145,32 @@ public class LoggingServiceV2Settings extends ServiceApiSettings {
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>
@@ -128,24 +178,31 @@ public SimpleCallSettings deleteLogSettings() {
return listMonitoredResourceDescriptorsSettings;
}
- public static LoggingServiceV2Settings defaultInstance() throws IOException {
- return newBuilder().build();
+ /**
+ * 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.getOrBuildChannel(),
- settingsBuilder.shouldAutoCloseChannel(),
- settingsBuilder.getOrBuildExecutor(),
- settingsBuilder.getConnectionSettings(),
+ settingsBuilder.getChannelProvider(),
+ settingsBuilder.getExecutorProvider(),
settingsBuilder.getGeneratorName(),
settingsBuilder.getGeneratorVersion(),
settingsBuilder.getClientLibName(),
@@ -214,6 +271,9 @@ public Iterable extractResources(
}
};
+ /**
+ * Builder for LoggingServiceV2Settings.
+ */
public static class Builder extends ServiceApiSettings.Builder {
private final ImmutableList methodSettingsBuilders;
@@ -270,35 +330,21 @@ public static class Builder extends ServiceApiSettings.Builder {
}
private Builder() {
- super(
- ConnectionSettings.builder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build());
-
- deleteLogSettings =
- SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_DELETE_LOG)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ super(DEFAULT_CONNECTION_SETTINGS);
+
+ deleteLogSettings = SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_DELETE_LOG);
writeLogEntriesSettings =
- SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_WRITE_LOG_ENTRIES)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(LoggingServiceV2Grpc.METHOD_WRITE_LOG_ENTRIES);
listLogEntriesSettings =
PageStreamingCallSettings.newBuilder(
- LoggingServiceV2Grpc.METHOD_LIST_LOG_ENTRIES, LIST_LOG_ENTRIES_PAGE_STR_DESC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("list"));
+ 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)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ LoggingServiceV2Grpc.METHOD_LIST_MONITORED_RESOURCE_DESCRIPTORS,
+ LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_DESC);
methodSettingsBuilders =
ImmutableList.of(
@@ -308,6 +354,31 @@ private Builder() {
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);
@@ -325,6 +396,17 @@ private Builder(LoggingServiceV2Settings settings) {
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);
@@ -338,8 +420,14 @@ public Builder provideChannelWith(ConnectionSettings settings) {
}
@Override
- public Builder setExecutor(ScheduledExecutorService executor) {
- super.setExecutor(executor);
+ public Builder provideChannelWith(Credentials credentials) {
+ super.provideChannelWith(credentials);
+ return this;
+ }
+
+ @Override
+ public Builder provideChannelWith(List scopes) {
+ super.provideChannelWith(scopes);
return this;
}
@@ -355,26 +443,43 @@ public Builder setClientLibHeader(String name, String 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>
diff --git a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java
index a5f2306577b2..adb4d1c325cd 100644
--- a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java
+++ b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Api.java
@@ -33,6 +33,7 @@
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;
@@ -48,6 +49,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
// Manually-added imports: add custom (non-generated) imports after this point.
@@ -55,27 +57,81 @@
/**
* Service Description:
*
+ *
This class provides the ability to make remote calls to the backing service through method
+ * calls that map to API methods. Sample code to get started:
+ *
+ *
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:
+ *
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
- public final Iterable listLogMetrics(ListLogMetricsRequest request) {
- return listLogMetricsIterableCallable().call(request);
+ public final PageAccessor listLogMetrics(ListLogMetricsRequest request) {
+ return listLogMetricsPagedCallable().call(request);
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists logs-based metrics.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
- public final ApiCallable>
- listLogMetricsIterableCallable() {
- return listLogMetricsIterableCallable;
+ public final ApiCallable>
+ listLogMetricsPagedCallable() {
+ return listLogMetricsPagedCallable;
}
// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
/**
* Lists logs-based metrics.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -304,12 +476,13 @@ public final ApiCallable getLogMetricCallable()
* 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 ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public final LogMetric createLogMetric(String projectName, LogMetric metric) {
+ PROJECT_PATH_TEMPLATE.validate(projectName);
+
CreateLogMetricRequest request =
CreateLogMetricRequest.newBuilder().setProjectName(projectName).setMetric(metric).build();
-
return createLogMetric(request);
}
@@ -317,11 +490,24 @@ public final LogMetric createLogMetric(String projectName, LogMetric metric) {
/**
* Creates a logs-based metric.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public LogMetric createLogMetric(CreateLogMetricRequest request) {
return createLogMetricCallable().call(request);
@@ -331,9 +517,23 @@ public LogMetric createLogMetric(CreateLogMetricRequest request) {
/**
* Creates a logs-based metric.
*
+ * Sample code:
+ *
+ *
*
*
*
@@ -357,12 +566,13 @@ public final ApiCallable createLogMetricCalla
* @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 ApiException if the remote call fails
+ * @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);
+
UpdateLogMetricRequest request =
UpdateLogMetricRequest.newBuilder().setMetricName(metricName).setMetric(metric).build();
-
return updateLogMetric(request);
}
@@ -370,11 +580,24 @@ public final LogMetric updateLogMetric(String metricName, LogMetric metric) {
/**
* Creates or updates a logs-based metric.
*
+ * Sample code:
+ *
+ *
*
*
*
* @param request The request object containing all of the parameters for the API call.
- * @throws ApiException if the remote call fails
+ * @throws com.google.api.gax.grpc.ApiException if the remote call fails
*/
public LogMetric updateLogMetric(UpdateLogMetricRequest request) {
return updateLogMetricCallable().call(request);
@@ -384,9 +607,23 @@ public LogMetric updateLogMetric(UpdateLogMetricRequest request) {
/**
* Creates or updates a logs-based metric.
*
+ * Sample code:
+ *
+ *
*
*
- * @throws ApiException if the remote call fails
*/
public final ApiCallable deleteLogMetricCallable() {
return deleteLogMetricCallable;
diff --git a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java
index 316a9851bf11..1308b95eb029 100644
--- a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java
+++ b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/MetricsServiceV2Settings.java
@@ -40,6 +40,7 @@
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;
@@ -57,12 +58,39 @@
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;
// Manually-added imports: add custom (non-generated) imports after this point.
// AUTO-GENERATED DOCUMENTATION AND CLASS - see instructions at the top of the file for editing.
+/**
+ * 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 ListLogMetrics to 30 seconds:
+ *
+ *
+ */
@javax.annotation.Generated("by GAPIC")
public class MetricsServiceV2Settings extends ServiceApiSettings {
@@ -94,6 +122,16 @@ public class MetricsServiceV2Settings extends ServiceApiSettings {
.add("https://www.googleapis.com/auth/cloud-platform")
.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;
@@ -102,45 +140,67 @@ public class MetricsServiceV2Settings extends ServiceApiSettings {
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;
}
- public static MetricsServiceV2Settings defaultInstance() throws IOException {
- return newBuilder().build();
+ /**
+ * 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.getOrBuildChannel(),
- settingsBuilder.shouldAutoCloseChannel(),
- settingsBuilder.getOrBuildExecutor(),
- settingsBuilder.getConnectionSettings(),
+ settingsBuilder.getChannelProvider(),
+ settingsBuilder.getExecutorProvider(),
settingsBuilder.getGeneratorName(),
settingsBuilder.getGeneratorVersion(),
settingsBuilder.getClientLibName(),
@@ -177,6 +237,9 @@ public Iterable extractResources(ListLogMetricsResponse payload) {
}
};
+ /**
+ * Builder for MetricsServiceV2Settings.
+ */
public static class Builder extends ServiceApiSettings.Builder {
private final ImmutableList methodSettingsBuilders;
@@ -220,38 +283,23 @@ public static class Builder extends ServiceApiSettings.Builder {
}
private Builder() {
- super(
- ConnectionSettings.builder()
- .setServiceAddress(DEFAULT_SERVICE_ADDRESS)
- .setPort(DEFAULT_SERVICE_PORT)
- .provideCredentialsWith(DEFAULT_SERVICE_SCOPES)
- .build());
+ super(DEFAULT_CONNECTION_SETTINGS);
listLogMetricsSettings =
PageStreamingCallSettings.newBuilder(
- MetricsServiceV2Grpc.METHOD_LIST_LOG_METRICS, LIST_LOG_METRICS_PAGE_STR_DESC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ MetricsServiceV2Grpc.METHOD_LIST_LOG_METRICS, LIST_LOG_METRICS_PAGE_STR_DESC);
getLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_GET_LOG_METRIC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_GET_LOG_METRIC);
createLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_CREATE_LOG_METRIC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_CREATE_LOG_METRIC);
updateLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_UPDATE_LOG_METRIC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_UPDATE_LOG_METRIC);
deleteLogMetricSettings =
- SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_DELETE_LOG_METRIC)
- .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
- .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default"));
+ SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_DELETE_LOG_METRIC);
methodSettingsBuilders =
ImmutableList.of(
@@ -262,6 +310,36 @@ private Builder() {
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);
@@ -280,6 +358,17 @@ private Builder(MetricsServiceV2Settings settings) {
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);
@@ -293,8 +382,14 @@ public Builder provideChannelWith(ConnectionSettings settings) {
}
@Override
- public Builder setExecutor(ScheduledExecutorService executor) {
- super.setExecutor(executor);
+ public Builder provideChannelWith(Credentials credentials) {
+ super.provideChannelWith(credentials);
+ return this;
+ }
+
+ @Override
+ public Builder provideChannelWith(List scopes) {
+ super.provideChannelWith(scopes);
return this;
}
@@ -310,29 +405,49 @@ public Builder setClientLibHeader(String name, String 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;
}
diff --git a/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/package-info.java b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/package-info.java
new file mode 100644
index 000000000000..81ee3d3fce7e
--- /dev/null
+++ b/gcloud-java-logging/src/main/java/com/google/cloud/logging/spi/v2/package-info.java
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+/*
+ * EDITING INSTRUCTIONS
+ * This file was automatically generated. For the short term, the process for
+ * refreshing this file will only be runnable by Google engineers.
+ * Manual additions are allowed because the refresh process performs
+ * a 3-way merge in order to preserve those manual additions. In order to not
+ * break the refresh process, additional documentation should be added between
+ * "manual edit" demarcations.
+ *
+ * Other generated files allow additional edits - see the editing instructions
+ * in those files for more details.
+ *
+ * Happy editing!
+ */
+
+/**
+ * A client to Google Cloud Logging API.
+ *
+ * The interfaces provided are listed below, along with a usage sample
+ *
+ * ===================
+ * LoggingServiceV2Api
+ * ===================
+ *
+ * Service Description: Service for ingesting and querying logs.
+ *
+ * Sample for LoggingServiceV2Api:
+ *