All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.cloud.logging.spi.v2.MetricsServiceV2Settings Maven / Gradle / Ivy

There is a newer version: 0.2.8
Show newest version
/*
 * 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 generated from the file
 * https://github.com/google/googleapis/blob/master/google/logging/v2/logging_metrics.proto
 * and updates to that file get reflected here through a refresh process.
 * For the short term, the refresh process 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, only certain types of modifications are
 * allowed.
 *
 * Allowed modifications - currently these are the only types allowed:
 * 1. New methods (these should be added to the end of the class)
 * 2. New imports
 * 3. Additional documentation between "manual edit" demarcations
 *
 * Happy editing!
 */

package com.google.cloud.logging.spi.v2;

import com.google.api.gax.core.ConnectionSettings;
import com.google.api.gax.core.RetrySettings;
import com.google.api.gax.grpc.ApiCallSettings;
import com.google.api.gax.grpc.PageStreamingCallSettings;
import com.google.api.gax.grpc.PageStreamingDescriptor;
import com.google.api.gax.grpc.ServiceApiSettings;
import com.google.api.gax.grpc.SimpleCallSettings;
import com.google.auth.Credentials;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.logging.v2.CreateLogMetricRequest;
import com.google.logging.v2.DeleteLogMetricRequest;
import com.google.logging.v2.GetLogMetricRequest;
import com.google.logging.v2.ListLogMetricsRequest;
import com.google.logging.v2.ListLogMetricsResponse;
import com.google.logging.v2.LogMetric;
import com.google.logging.v2.MetricsServiceV2Grpc;
import com.google.logging.v2.UpdateLogMetricRequest;
import com.google.protobuf.Empty;
import io.grpc.ManagedChannel;
import io.grpc.Status;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import org.joda.time.Duration;

// 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: * *

 * 
 * MetricsServiceV2Settings.Builder metricsServiceV2SettingsBuilder =
 *     MetricsServiceV2Settings.defaultBuilder();
 * metricsServiceV2SettingsBuilder.ListLogMetricsSettings().getRetrySettingsBuilder()
 *     .setTotalTimeout(Duration.standardSeconds(30));
 * MetricsServiceV2Settings metricsServiceV2Settings = metricsServiceV2SettingsBuilder.build();
 * 
 * 
*/ @javax.annotation.Generated("by GAPIC") public class MetricsServiceV2Settings extends ServiceApiSettings { /** * The default address of the service. * * * */ public static final String DEFAULT_SERVICE_ADDRESS = "logging.googleapis.com"; /** * The default port of the service. * * * */ public static final int DEFAULT_SERVICE_PORT = 443; /** * The default scopes of the service. */ public static final ImmutableList DEFAULT_SERVICE_SCOPES = ImmutableList.builder() .add("https://www.googleapis.com/auth/logging.write") .add("https://www.googleapis.com/auth/logging.admin") .add("https://www.googleapis.com/auth/logging.read") .add("https://www.googleapis.com/auth/cloud-platform.read-only") .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; private final SimpleCallSettings getLogMetricSettings; private final SimpleCallSettings createLogMetricSettings; private final SimpleCallSettings updateLogMetricSettings; private final SimpleCallSettings deleteLogMetricSettings; /** * Returns the object with the settings used for calls to listLogMetrics. */ public PageStreamingCallSettings listLogMetricsSettings() { return listLogMetricsSettings; } /** * Returns the object with the settings used for calls to getLogMetric. */ public SimpleCallSettings getLogMetricSettings() { return getLogMetricSettings; } /** * Returns the object with the settings used for calls to createLogMetric. */ public SimpleCallSettings createLogMetricSettings() { return createLogMetricSettings; } /** * Returns the object with the settings used for calls to updateLogMetric. */ public SimpleCallSettings updateLogMetricSettings() { return updateLogMetricSettings; } /** * Returns the object with the settings used for calls to deleteLogMetric. */ public SimpleCallSettings deleteLogMetricSettings() { return deleteLogMetricSettings; } /** * Returns a builder for this class with recommended defaults. */ public static Builder defaultBuilder() { return Builder.createDefault(); } /** * Returns a new builder for this class. */ public static Builder newBuilder() { return new Builder(); } /** * Returns a builder containing all the values of this settings class. */ public Builder toBuilder() { return new Builder(this); } private MetricsServiceV2Settings(Builder settingsBuilder) throws IOException { super( settingsBuilder.getChannelProvider(), settingsBuilder.getExecutorProvider(), settingsBuilder.getGeneratorName(), settingsBuilder.getGeneratorVersion(), settingsBuilder.getClientLibName(), settingsBuilder.getClientLibVersion()); listLogMetricsSettings = settingsBuilder.listLogMetricsSettings().build(); getLogMetricSettings = settingsBuilder.getLogMetricSettings().build(); createLogMetricSettings = settingsBuilder.createLogMetricSettings().build(); updateLogMetricSettings = settingsBuilder.updateLogMetricSettings().build(); deleteLogMetricSettings = settingsBuilder.deleteLogMetricSettings().build(); } private static PageStreamingDescriptor LIST_LOG_METRICS_PAGE_STR_DESC = new PageStreamingDescriptor() { @Override public Object emptyToken() { return ""; } @Override public ListLogMetricsRequest injectToken(ListLogMetricsRequest payload, Object token) { return ListLogMetricsRequest.newBuilder(payload).setPageToken((String) token).build(); } @Override public Object extractNextToken(ListLogMetricsResponse payload) { return payload.getNextPageToken(); } @Override public Iterable extractResources(ListLogMetricsResponse payload) { return payload.getMetricsList(); } }; /** * Builder for MetricsServiceV2Settings. */ public static class Builder extends ServiceApiSettings.Builder { private final ImmutableList methodSettingsBuilders; private PageStreamingCallSettings.Builder< ListLogMetricsRequest, ListLogMetricsResponse, LogMetric> listLogMetricsSettings; private SimpleCallSettings.Builder getLogMetricSettings; private SimpleCallSettings.Builder createLogMetricSettings; private SimpleCallSettings.Builder updateLogMetricSettings; private SimpleCallSettings.Builder deleteLogMetricSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); definitions.put( "idempotent", Sets.immutableEnumSet( Lists.newArrayList( Status.Code.DEADLINE_EXCEEDED, Status.Code.UNAVAILABLE))); definitions.put("non_idempotent", Sets.immutableEnumSet(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } private static final ImmutableMap RETRY_PARAM_DEFINITIONS; static { ImmutableMap.Builder definitions = ImmutableMap.builder(); RetrySettings.Builder settingsBuilder = null; settingsBuilder = RetrySettings.newBuilder() .setInitialRetryDelay(Duration.millis(100L)) .setRetryDelayMultiplier(1.2) .setMaxRetryDelay(Duration.millis(1000L)) .setInitialRpcTimeout(Duration.millis(2000L)) .setRpcTimeoutMultiplier(1.5) .setMaxRpcTimeout(Duration.millis(30000L)) .setTotalTimeout(Duration.millis(45000L)); definitions.put("default", settingsBuilder); RETRY_PARAM_DEFINITIONS = definitions.build(); } private Builder() { super(DEFAULT_CONNECTION_SETTINGS); listLogMetricsSettings = PageStreamingCallSettings.newBuilder( MetricsServiceV2Grpc.METHOD_LIST_LOG_METRICS, LIST_LOG_METRICS_PAGE_STR_DESC); getLogMetricSettings = SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_GET_LOG_METRIC); createLogMetricSettings = SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_CREATE_LOG_METRIC); updateLogMetricSettings = SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_UPDATE_LOG_METRIC); deleteLogMetricSettings = SimpleCallSettings.newBuilder(MetricsServiceV2Grpc.METHOD_DELETE_LOG_METRIC); methodSettingsBuilders = ImmutableList.of( listLogMetricsSettings, getLogMetricSettings, createLogMetricSettings, updateLogMetricSettings, deleteLogMetricSettings); } private static Builder createDefault() { Builder builder = new Builder(); builder .listLogMetricsSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default")); builder .getLogMetricSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default")); builder .createLogMetricSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default")); builder .updateLogMetricSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default")); builder .deleteLogMetricSettings() .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) .setRetrySettingsBuilder(RETRY_PARAM_DEFINITIONS.get("default")); return builder; } private Builder(MetricsServiceV2Settings settings) { super(settings); listLogMetricsSettings = settings.listLogMetricsSettings.toBuilder(); getLogMetricSettings = settings.getLogMetricSettings.toBuilder(); createLogMetricSettings = settings.createLogMetricSettings.toBuilder(); updateLogMetricSettings = settings.updateLogMetricSettings.toBuilder(); deleteLogMetricSettings = settings.deleteLogMetricSettings.toBuilder(); methodSettingsBuilders = ImmutableList.of( listLogMetricsSettings, getLogMetricSettings, createLogMetricSettings, updateLogMetricSettings, deleteLogMetricSettings); } @Override protected ConnectionSettings getDefaultConnectionSettings() { return DEFAULT_CONNECTION_SETTINGS; } @Override public Builder provideExecutorWith(ScheduledExecutorService executor, boolean shouldAutoClose) { super.provideExecutorWith(executor, shouldAutoClose); return this; } @Override public Builder provideChannelWith(ManagedChannel channel, boolean shouldAutoClose) { super.provideChannelWith(channel, shouldAutoClose); return this; } @Override public Builder provideChannelWith(ConnectionSettings settings) { super.provideChannelWith(settings); return this; } @Override public Builder provideChannelWith(Credentials credentials) { super.provideChannelWith(credentials); return this; } @Override public Builder provideChannelWith(List scopes) { super.provideChannelWith(scopes); return this; } @Override public Builder setGeneratorHeader(String name, String version) { super.setGeneratorHeader(name, version); return this; } @Override public Builder setClientLibHeader(String name, String version) { super.setClientLibHeader(name, version); return this; } /** * Applies the given settings to all of the API methods in this service. Only * values that are non-null will be applied, so this method is not capable * of un-setting any values. */ public Builder applyToAllApiMethods(ApiCallSettings.Builder apiCallSettings) throws Exception { super.applyToAllApiMethods(methodSettingsBuilders, apiCallSettings); return this; } /** * Returns the builder for the settings used for calls to listLogMetrics. */ public PageStreamingCallSettings.Builder< ListLogMetricsRequest, ListLogMetricsResponse, LogMetric> listLogMetricsSettings() { return listLogMetricsSettings; } /** * Returns the builder for the settings used for calls to getLogMetric. */ public SimpleCallSettings.Builder getLogMetricSettings() { return getLogMetricSettings; } /** * Returns the builder for the settings used for calls to createLogMetric. */ public SimpleCallSettings.Builder createLogMetricSettings() { return createLogMetricSettings; } /** * Returns the builder for the settings used for calls to updateLogMetric. */ public SimpleCallSettings.Builder updateLogMetricSettings() { return updateLogMetricSettings; } /** * Returns the builder for the settings used for calls to deleteLogMetric. */ public SimpleCallSettings.Builder deleteLogMetricSettings() { return deleteLogMetricSettings; } @Override public MetricsServiceV2Settings build() throws IOException { return new MetricsServiceV2Settings(this); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy