1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.cloud.compute.v1; 18 19 import static com.google.cloud.compute.v1.RoutesClient.ListPagedResponse; 20 21 import com.google.api.core.ApiFunction; 22 import com.google.api.core.BetaApi; 23 import com.google.api.gax.core.GoogleCredentialsProvider; 24 import com.google.api.gax.core.InstantiatingExecutorProvider; 25 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 26 import com.google.api.gax.rpc.ApiClientHeaderProvider; 27 import com.google.api.gax.rpc.ClientContext; 28 import com.google.api.gax.rpc.ClientSettings; 29 import com.google.api.gax.rpc.OperationCallSettings; 30 import com.google.api.gax.rpc.PagedCallSettings; 31 import com.google.api.gax.rpc.TransportChannelProvider; 32 import com.google.api.gax.rpc.UnaryCallSettings; 33 import com.google.cloud.compute.v1.stub.RoutesStubSettings; 34 import java.io.IOException; 35 import java.util.List; 36 import javax.annotation.Generated; 37 38 // AUTO-GENERATED DOCUMENTATION AND CLASS. 39 /** 40 * Settings class to configure an instance of {@link RoutesClient}. 41 * 42 * <p>The default instance has everything set to sensible defaults: 43 * 44 * <ul> 45 * <li>The default service address (compute.googleapis.com) and default port (443) are used. 46 * <li>Credentials are acquired automatically through Application Default Credentials. 47 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 48 * </ul> 49 * 50 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 51 * build() is called, the tree of builders is called to create the complete settings object. 52 * 53 * <p>For example, to set the total timeout of get to 30 seconds: 54 * 55 * <pre>{@code 56 * // This snippet has been automatically generated and should be regarded as a code template only. 57 * // It will require modifications to work: 58 * // - It may require correct/in-range values for request initialization. 59 * // - It may require specifying regional endpoints when creating the service client as shown in 60 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 61 * RoutesSettings.Builder routesSettingsBuilder = RoutesSettings.newBuilder(); 62 * routesSettingsBuilder 63 * .getSettings() 64 * .setRetrySettings( 65 * routesSettingsBuilder 66 * .getSettings() 67 * .getRetrySettings() 68 * .toBuilder() 69 * .setTotalTimeout(Duration.ofSeconds(30)) 70 * .build()); 71 * RoutesSettings routesSettings = routesSettingsBuilder.build(); 72 * }</pre> 73 */ 74 @Generated("by gapic-generator-java") 75 public class RoutesSettings extends ClientSettings<RoutesSettings> { 76 77 /** Returns the object with the settings used for calls to delete. */ deleteSettings()78 public UnaryCallSettings<DeleteRouteRequest, Operation> deleteSettings() { 79 return ((RoutesStubSettings) getStubSettings()).deleteSettings(); 80 } 81 82 /** Returns the object with the settings used for calls to delete. */ deleteOperationSettings()83 public OperationCallSettings<DeleteRouteRequest, Operation, Operation> deleteOperationSettings() { 84 return ((RoutesStubSettings) getStubSettings()).deleteOperationSettings(); 85 } 86 87 /** Returns the object with the settings used for calls to get. */ getSettings()88 public UnaryCallSettings<GetRouteRequest, Route> getSettings() { 89 return ((RoutesStubSettings) getStubSettings()).getSettings(); 90 } 91 92 /** Returns the object with the settings used for calls to insert. */ insertSettings()93 public UnaryCallSettings<InsertRouteRequest, Operation> insertSettings() { 94 return ((RoutesStubSettings) getStubSettings()).insertSettings(); 95 } 96 97 /** Returns the object with the settings used for calls to insert. */ insertOperationSettings()98 public OperationCallSettings<InsertRouteRequest, Operation, Operation> insertOperationSettings() { 99 return ((RoutesStubSettings) getStubSettings()).insertOperationSettings(); 100 } 101 102 /** Returns the object with the settings used for calls to list. */ listSettings()103 public PagedCallSettings<ListRoutesRequest, RouteList, ListPagedResponse> listSettings() { 104 return ((RoutesStubSettings) getStubSettings()).listSettings(); 105 } 106 create(RoutesStubSettings stub)107 public static final RoutesSettings create(RoutesStubSettings stub) throws IOException { 108 return new RoutesSettings.Builder(stub.toBuilder()).build(); 109 } 110 111 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()112 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 113 return RoutesStubSettings.defaultExecutorProviderBuilder(); 114 } 115 116 /** Returns the default service endpoint. */ getDefaultEndpoint()117 public static String getDefaultEndpoint() { 118 return RoutesStubSettings.getDefaultEndpoint(); 119 } 120 121 /** Returns the default service scopes. */ getDefaultServiceScopes()122 public static List<String> getDefaultServiceScopes() { 123 return RoutesStubSettings.getDefaultServiceScopes(); 124 } 125 126 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()127 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 128 return RoutesStubSettings.defaultCredentialsProviderBuilder(); 129 } 130 131 /** Returns a builder for the default ChannelProvider for this service. */ 132 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()133 defaultHttpJsonTransportProviderBuilder() { 134 return RoutesStubSettings.defaultHttpJsonTransportProviderBuilder(); 135 } 136 defaultTransportChannelProvider()137 public static TransportChannelProvider defaultTransportChannelProvider() { 138 return RoutesStubSettings.defaultTransportChannelProvider(); 139 } 140 141 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()142 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 143 return RoutesStubSettings.defaultApiClientHeaderProviderBuilder(); 144 } 145 146 /** Returns a new builder for this class. */ newBuilder()147 public static Builder newBuilder() { 148 return Builder.createDefault(); 149 } 150 151 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)152 public static Builder newBuilder(ClientContext clientContext) { 153 return new Builder(clientContext); 154 } 155 156 /** Returns a builder containing all the values of this settings class. */ toBuilder()157 public Builder toBuilder() { 158 return new Builder(this); 159 } 160 RoutesSettings(Builder settingsBuilder)161 protected RoutesSettings(Builder settingsBuilder) throws IOException { 162 super(settingsBuilder); 163 } 164 165 /** Builder for RoutesSettings. */ 166 public static class Builder extends ClientSettings.Builder<RoutesSettings, Builder> { 167 Builder()168 protected Builder() throws IOException { 169 this(((ClientContext) null)); 170 } 171 Builder(ClientContext clientContext)172 protected Builder(ClientContext clientContext) { 173 super(RoutesStubSettings.newBuilder(clientContext)); 174 } 175 Builder(RoutesSettings settings)176 protected Builder(RoutesSettings settings) { 177 super(settings.getStubSettings().toBuilder()); 178 } 179 Builder(RoutesStubSettings.Builder stubSettings)180 protected Builder(RoutesStubSettings.Builder stubSettings) { 181 super(stubSettings); 182 } 183 createDefault()184 private static Builder createDefault() { 185 return new Builder(RoutesStubSettings.newBuilder()); 186 } 187 getStubSettingsBuilder()188 public RoutesStubSettings.Builder getStubSettingsBuilder() { 189 return ((RoutesStubSettings.Builder) getStubSettings()); 190 } 191 192 /** 193 * Applies the given settings updater function to all of the unary API methods in this service. 194 * 195 * <p>Note: This method does not support applying settings to streaming methods. 196 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)197 public Builder applyToAllUnaryMethods( 198 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 199 super.applyToAllUnaryMethods( 200 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 201 return this; 202 } 203 204 /** Returns the builder for the settings used for calls to delete. */ deleteSettings()205 public UnaryCallSettings.Builder<DeleteRouteRequest, Operation> deleteSettings() { 206 return getStubSettingsBuilder().deleteSettings(); 207 } 208 209 /** Returns the builder for the settings used for calls to delete. */ 210 public OperationCallSettings.Builder<DeleteRouteRequest, Operation, Operation> deleteOperationSettings()211 deleteOperationSettings() { 212 return getStubSettingsBuilder().deleteOperationSettings(); 213 } 214 215 /** Returns the builder for the settings used for calls to get. */ getSettings()216 public UnaryCallSettings.Builder<GetRouteRequest, Route> getSettings() { 217 return getStubSettingsBuilder().getSettings(); 218 } 219 220 /** Returns the builder for the settings used for calls to insert. */ insertSettings()221 public UnaryCallSettings.Builder<InsertRouteRequest, Operation> insertSettings() { 222 return getStubSettingsBuilder().insertSettings(); 223 } 224 225 /** Returns the builder for the settings used for calls to insert. */ 226 public OperationCallSettings.Builder<InsertRouteRequest, Operation, Operation> insertOperationSettings()227 insertOperationSettings() { 228 return getStubSettingsBuilder().insertOperationSettings(); 229 } 230 231 /** Returns the builder for the settings used for calls to list. */ 232 public PagedCallSettings.Builder<ListRoutesRequest, RouteList, ListPagedResponse> listSettings()233 listSettings() { 234 return getStubSettingsBuilder().listSettings(); 235 } 236 237 @Override build()238 public RoutesSettings build() throws IOException { 239 return new RoutesSettings(this); 240 } 241 } 242 } 243