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.retail.v2; 18 19 import static com.google.cloud.retail.v2.CatalogServiceClient.ListCatalogsPagedResponse; 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.grpc.InstantiatingGrpcChannelProvider; 26 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 27 import com.google.api.gax.rpc.ApiClientHeaderProvider; 28 import com.google.api.gax.rpc.ClientContext; 29 import com.google.api.gax.rpc.ClientSettings; 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.retail.v2.stub.CatalogServiceStubSettings; 34 import com.google.protobuf.Empty; 35 import java.io.IOException; 36 import java.util.List; 37 import javax.annotation.Generated; 38 39 // AUTO-GENERATED DOCUMENTATION AND CLASS. 40 /** 41 * Settings class to configure an instance of {@link CatalogServiceClient}. 42 * 43 * <p>The default instance has everything set to sensible defaults: 44 * 45 * <ul> 46 * <li>The default service address (retail.googleapis.com) and default port (443) are used. 47 * <li>Credentials are acquired automatically through Application Default Credentials. 48 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 49 * </ul> 50 * 51 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 52 * build() is called, the tree of builders is called to create the complete settings object. 53 * 54 * <p>For example, to set the total timeout of updateCatalog to 30 seconds: 55 * 56 * <pre>{@code 57 * // This snippet has been automatically generated and should be regarded as a code template only. 58 * // It will require modifications to work: 59 * // - It may require correct/in-range values for request initialization. 60 * // - It may require specifying regional endpoints when creating the service client as shown in 61 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 62 * CatalogServiceSettings.Builder catalogServiceSettingsBuilder = 63 * CatalogServiceSettings.newBuilder(); 64 * catalogServiceSettingsBuilder 65 * .updateCatalogSettings() 66 * .setRetrySettings( 67 * catalogServiceSettingsBuilder 68 * .updateCatalogSettings() 69 * .getRetrySettings() 70 * .toBuilder() 71 * .setTotalTimeout(Duration.ofSeconds(30)) 72 * .build()); 73 * CatalogServiceSettings catalogServiceSettings = catalogServiceSettingsBuilder.build(); 74 * }</pre> 75 */ 76 @Generated("by gapic-generator-java") 77 public class CatalogServiceSettings extends ClientSettings<CatalogServiceSettings> { 78 79 /** Returns the object with the settings used for calls to listCatalogs. */ 80 public PagedCallSettings<ListCatalogsRequest, ListCatalogsResponse, ListCatalogsPagedResponse> listCatalogsSettings()81 listCatalogsSettings() { 82 return ((CatalogServiceStubSettings) getStubSettings()).listCatalogsSettings(); 83 } 84 85 /** Returns the object with the settings used for calls to updateCatalog. */ updateCatalogSettings()86 public UnaryCallSettings<UpdateCatalogRequest, Catalog> updateCatalogSettings() { 87 return ((CatalogServiceStubSettings) getStubSettings()).updateCatalogSettings(); 88 } 89 90 /** Returns the object with the settings used for calls to setDefaultBranch. */ setDefaultBranchSettings()91 public UnaryCallSettings<SetDefaultBranchRequest, Empty> setDefaultBranchSettings() { 92 return ((CatalogServiceStubSettings) getStubSettings()).setDefaultBranchSettings(); 93 } 94 95 /** Returns the object with the settings used for calls to getDefaultBranch. */ 96 public UnaryCallSettings<GetDefaultBranchRequest, GetDefaultBranchResponse> getDefaultBranchSettings()97 getDefaultBranchSettings() { 98 return ((CatalogServiceStubSettings) getStubSettings()).getDefaultBranchSettings(); 99 } 100 101 /** Returns the object with the settings used for calls to getCompletionConfig. */ 102 public UnaryCallSettings<GetCompletionConfigRequest, CompletionConfig> getCompletionConfigSettings()103 getCompletionConfigSettings() { 104 return ((CatalogServiceStubSettings) getStubSettings()).getCompletionConfigSettings(); 105 } 106 107 /** Returns the object with the settings used for calls to updateCompletionConfig. */ 108 public UnaryCallSettings<UpdateCompletionConfigRequest, CompletionConfig> updateCompletionConfigSettings()109 updateCompletionConfigSettings() { 110 return ((CatalogServiceStubSettings) getStubSettings()).updateCompletionConfigSettings(); 111 } 112 113 /** Returns the object with the settings used for calls to getAttributesConfig. */ 114 public UnaryCallSettings<GetAttributesConfigRequest, AttributesConfig> getAttributesConfigSettings()115 getAttributesConfigSettings() { 116 return ((CatalogServiceStubSettings) getStubSettings()).getAttributesConfigSettings(); 117 } 118 119 /** Returns the object with the settings used for calls to updateAttributesConfig. */ 120 public UnaryCallSettings<UpdateAttributesConfigRequest, AttributesConfig> updateAttributesConfigSettings()121 updateAttributesConfigSettings() { 122 return ((CatalogServiceStubSettings) getStubSettings()).updateAttributesConfigSettings(); 123 } 124 125 /** Returns the object with the settings used for calls to addCatalogAttribute. */ 126 public UnaryCallSettings<AddCatalogAttributeRequest, AttributesConfig> addCatalogAttributeSettings()127 addCatalogAttributeSettings() { 128 return ((CatalogServiceStubSettings) getStubSettings()).addCatalogAttributeSettings(); 129 } 130 131 /** Returns the object with the settings used for calls to removeCatalogAttribute. */ 132 public UnaryCallSettings<RemoveCatalogAttributeRequest, AttributesConfig> removeCatalogAttributeSettings()133 removeCatalogAttributeSettings() { 134 return ((CatalogServiceStubSettings) getStubSettings()).removeCatalogAttributeSettings(); 135 } 136 137 /** Returns the object with the settings used for calls to replaceCatalogAttribute. */ 138 public UnaryCallSettings<ReplaceCatalogAttributeRequest, AttributesConfig> replaceCatalogAttributeSettings()139 replaceCatalogAttributeSettings() { 140 return ((CatalogServiceStubSettings) getStubSettings()).replaceCatalogAttributeSettings(); 141 } 142 create(CatalogServiceStubSettings stub)143 public static final CatalogServiceSettings create(CatalogServiceStubSettings stub) 144 throws IOException { 145 return new CatalogServiceSettings.Builder(stub.toBuilder()).build(); 146 } 147 148 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()149 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 150 return CatalogServiceStubSettings.defaultExecutorProviderBuilder(); 151 } 152 153 /** Returns the default service endpoint. */ getDefaultEndpoint()154 public static String getDefaultEndpoint() { 155 return CatalogServiceStubSettings.getDefaultEndpoint(); 156 } 157 158 /** Returns the default service scopes. */ getDefaultServiceScopes()159 public static List<String> getDefaultServiceScopes() { 160 return CatalogServiceStubSettings.getDefaultServiceScopes(); 161 } 162 163 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()164 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 165 return CatalogServiceStubSettings.defaultCredentialsProviderBuilder(); 166 } 167 168 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()169 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 170 return CatalogServiceStubSettings.defaultGrpcTransportProviderBuilder(); 171 } 172 173 /** Returns a builder for the default REST ChannelProvider for this service. */ 174 @BetaApi 175 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()176 defaultHttpJsonTransportProviderBuilder() { 177 return CatalogServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); 178 } 179 defaultTransportChannelProvider()180 public static TransportChannelProvider defaultTransportChannelProvider() { 181 return CatalogServiceStubSettings.defaultTransportChannelProvider(); 182 } 183 184 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()185 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 186 return CatalogServiceStubSettings.defaultApiClientHeaderProviderBuilder(); 187 } 188 189 /** Returns a new gRPC builder for this class. */ newBuilder()190 public static Builder newBuilder() { 191 return Builder.createDefault(); 192 } 193 194 /** Returns a new REST builder for this class. */ 195 @BetaApi newHttpJsonBuilder()196 public static Builder newHttpJsonBuilder() { 197 return Builder.createHttpJsonDefault(); 198 } 199 200 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)201 public static Builder newBuilder(ClientContext clientContext) { 202 return new Builder(clientContext); 203 } 204 205 /** Returns a builder containing all the values of this settings class. */ toBuilder()206 public Builder toBuilder() { 207 return new Builder(this); 208 } 209 CatalogServiceSettings(Builder settingsBuilder)210 protected CatalogServiceSettings(Builder settingsBuilder) throws IOException { 211 super(settingsBuilder); 212 } 213 214 /** Builder for CatalogServiceSettings. */ 215 public static class Builder extends ClientSettings.Builder<CatalogServiceSettings, Builder> { 216 Builder()217 protected Builder() throws IOException { 218 this(((ClientContext) null)); 219 } 220 Builder(ClientContext clientContext)221 protected Builder(ClientContext clientContext) { 222 super(CatalogServiceStubSettings.newBuilder(clientContext)); 223 } 224 Builder(CatalogServiceSettings settings)225 protected Builder(CatalogServiceSettings settings) { 226 super(settings.getStubSettings().toBuilder()); 227 } 228 Builder(CatalogServiceStubSettings.Builder stubSettings)229 protected Builder(CatalogServiceStubSettings.Builder stubSettings) { 230 super(stubSettings); 231 } 232 createDefault()233 private static Builder createDefault() { 234 return new Builder(CatalogServiceStubSettings.newBuilder()); 235 } 236 237 @BetaApi createHttpJsonDefault()238 private static Builder createHttpJsonDefault() { 239 return new Builder(CatalogServiceStubSettings.newHttpJsonBuilder()); 240 } 241 getStubSettingsBuilder()242 public CatalogServiceStubSettings.Builder getStubSettingsBuilder() { 243 return ((CatalogServiceStubSettings.Builder) getStubSettings()); 244 } 245 246 /** 247 * Applies the given settings updater function to all of the unary API methods in this service. 248 * 249 * <p>Note: This method does not support applying settings to streaming methods. 250 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)251 public Builder applyToAllUnaryMethods( 252 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 253 super.applyToAllUnaryMethods( 254 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 255 return this; 256 } 257 258 /** Returns the builder for the settings used for calls to listCatalogs. */ 259 public PagedCallSettings.Builder< 260 ListCatalogsRequest, ListCatalogsResponse, ListCatalogsPagedResponse> listCatalogsSettings()261 listCatalogsSettings() { 262 return getStubSettingsBuilder().listCatalogsSettings(); 263 } 264 265 /** Returns the builder for the settings used for calls to updateCatalog. */ updateCatalogSettings()266 public UnaryCallSettings.Builder<UpdateCatalogRequest, Catalog> updateCatalogSettings() { 267 return getStubSettingsBuilder().updateCatalogSettings(); 268 } 269 270 /** Returns the builder for the settings used for calls to setDefaultBranch. */ setDefaultBranchSettings()271 public UnaryCallSettings.Builder<SetDefaultBranchRequest, Empty> setDefaultBranchSettings() { 272 return getStubSettingsBuilder().setDefaultBranchSettings(); 273 } 274 275 /** Returns the builder for the settings used for calls to getDefaultBranch. */ 276 public UnaryCallSettings.Builder<GetDefaultBranchRequest, GetDefaultBranchResponse> getDefaultBranchSettings()277 getDefaultBranchSettings() { 278 return getStubSettingsBuilder().getDefaultBranchSettings(); 279 } 280 281 /** Returns the builder for the settings used for calls to getCompletionConfig. */ 282 public UnaryCallSettings.Builder<GetCompletionConfigRequest, CompletionConfig> getCompletionConfigSettings()283 getCompletionConfigSettings() { 284 return getStubSettingsBuilder().getCompletionConfigSettings(); 285 } 286 287 /** Returns the builder for the settings used for calls to updateCompletionConfig. */ 288 public UnaryCallSettings.Builder<UpdateCompletionConfigRequest, CompletionConfig> updateCompletionConfigSettings()289 updateCompletionConfigSettings() { 290 return getStubSettingsBuilder().updateCompletionConfigSettings(); 291 } 292 293 /** Returns the builder for the settings used for calls to getAttributesConfig. */ 294 public UnaryCallSettings.Builder<GetAttributesConfigRequest, AttributesConfig> getAttributesConfigSettings()295 getAttributesConfigSettings() { 296 return getStubSettingsBuilder().getAttributesConfigSettings(); 297 } 298 299 /** Returns the builder for the settings used for calls to updateAttributesConfig. */ 300 public UnaryCallSettings.Builder<UpdateAttributesConfigRequest, AttributesConfig> updateAttributesConfigSettings()301 updateAttributesConfigSettings() { 302 return getStubSettingsBuilder().updateAttributesConfigSettings(); 303 } 304 305 /** Returns the builder for the settings used for calls to addCatalogAttribute. */ 306 public UnaryCallSettings.Builder<AddCatalogAttributeRequest, AttributesConfig> addCatalogAttributeSettings()307 addCatalogAttributeSettings() { 308 return getStubSettingsBuilder().addCatalogAttributeSettings(); 309 } 310 311 /** Returns the builder for the settings used for calls to removeCatalogAttribute. */ 312 public UnaryCallSettings.Builder<RemoveCatalogAttributeRequest, AttributesConfig> removeCatalogAttributeSettings()313 removeCatalogAttributeSettings() { 314 return getStubSettingsBuilder().removeCatalogAttributeSettings(); 315 } 316 317 /** Returns the builder for the settings used for calls to replaceCatalogAttribute. */ 318 public UnaryCallSettings.Builder<ReplaceCatalogAttributeRequest, AttributesConfig> replaceCatalogAttributeSettings()319 replaceCatalogAttributeSettings() { 320 return getStubSettingsBuilder().replaceCatalogAttributeSettings(); 321 } 322 323 @Override build()324 public CatalogServiceSettings build() throws IOException { 325 return new CatalogServiceSettings(this); 326 } 327 } 328 } 329