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.recommender.v1; 18 19 import static com.google.cloud.recommender.v1.RecommenderClient.ListInsightsPagedResponse; 20 import static com.google.cloud.recommender.v1.RecommenderClient.ListRecommendationsPagedResponse; 21 22 import com.google.api.core.ApiFunction; 23 import com.google.api.core.BetaApi; 24 import com.google.api.gax.core.GoogleCredentialsProvider; 25 import com.google.api.gax.core.InstantiatingExecutorProvider; 26 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; 27 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 28 import com.google.api.gax.rpc.ApiClientHeaderProvider; 29 import com.google.api.gax.rpc.ClientContext; 30 import com.google.api.gax.rpc.ClientSettings; 31 import com.google.api.gax.rpc.PagedCallSettings; 32 import com.google.api.gax.rpc.TransportChannelProvider; 33 import com.google.api.gax.rpc.UnaryCallSettings; 34 import com.google.cloud.recommender.v1.stub.RecommenderStubSettings; 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 RecommenderClient}. 42 * 43 * <p>The default instance has everything set to sensible defaults: 44 * 45 * <ul> 46 * <li>The default service address (recommender.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 getInsight 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 * RecommenderSettings.Builder recommenderSettingsBuilder = RecommenderSettings.newBuilder(); 63 * recommenderSettingsBuilder 64 * .getInsightSettings() 65 * .setRetrySettings( 66 * recommenderSettingsBuilder 67 * .getInsightSettings() 68 * .getRetrySettings() 69 * .toBuilder() 70 * .setTotalTimeout(Duration.ofSeconds(30)) 71 * .build()); 72 * RecommenderSettings recommenderSettings = recommenderSettingsBuilder.build(); 73 * }</pre> 74 */ 75 @Generated("by gapic-generator-java") 76 public class RecommenderSettings extends ClientSettings<RecommenderSettings> { 77 78 /** Returns the object with the settings used for calls to listInsights. */ 79 public PagedCallSettings<ListInsightsRequest, ListInsightsResponse, ListInsightsPagedResponse> listInsightsSettings()80 listInsightsSettings() { 81 return ((RecommenderStubSettings) getStubSettings()).listInsightsSettings(); 82 } 83 84 /** Returns the object with the settings used for calls to getInsight. */ getInsightSettings()85 public UnaryCallSettings<GetInsightRequest, Insight> getInsightSettings() { 86 return ((RecommenderStubSettings) getStubSettings()).getInsightSettings(); 87 } 88 89 /** Returns the object with the settings used for calls to markInsightAccepted. */ markInsightAcceptedSettings()90 public UnaryCallSettings<MarkInsightAcceptedRequest, Insight> markInsightAcceptedSettings() { 91 return ((RecommenderStubSettings) getStubSettings()).markInsightAcceptedSettings(); 92 } 93 94 /** Returns the object with the settings used for calls to listRecommendations. */ 95 public PagedCallSettings< 96 ListRecommendationsRequest, ListRecommendationsResponse, ListRecommendationsPagedResponse> listRecommendationsSettings()97 listRecommendationsSettings() { 98 return ((RecommenderStubSettings) getStubSettings()).listRecommendationsSettings(); 99 } 100 101 /** Returns the object with the settings used for calls to getRecommendation. */ getRecommendationSettings()102 public UnaryCallSettings<GetRecommendationRequest, Recommendation> getRecommendationSettings() { 103 return ((RecommenderStubSettings) getStubSettings()).getRecommendationSettings(); 104 } 105 106 /** Returns the object with the settings used for calls to markRecommendationClaimed. */ 107 public UnaryCallSettings<MarkRecommendationClaimedRequest, Recommendation> markRecommendationClaimedSettings()108 markRecommendationClaimedSettings() { 109 return ((RecommenderStubSettings) getStubSettings()).markRecommendationClaimedSettings(); 110 } 111 112 /** Returns the object with the settings used for calls to markRecommendationSucceeded. */ 113 public UnaryCallSettings<MarkRecommendationSucceededRequest, Recommendation> markRecommendationSucceededSettings()114 markRecommendationSucceededSettings() { 115 return ((RecommenderStubSettings) getStubSettings()).markRecommendationSucceededSettings(); 116 } 117 118 /** Returns the object with the settings used for calls to markRecommendationFailed. */ 119 public UnaryCallSettings<MarkRecommendationFailedRequest, Recommendation> markRecommendationFailedSettings()120 markRecommendationFailedSettings() { 121 return ((RecommenderStubSettings) getStubSettings()).markRecommendationFailedSettings(); 122 } 123 124 /** Returns the object with the settings used for calls to getRecommenderConfig. */ 125 public UnaryCallSettings<GetRecommenderConfigRequest, RecommenderConfig> getRecommenderConfigSettings()126 getRecommenderConfigSettings() { 127 return ((RecommenderStubSettings) getStubSettings()).getRecommenderConfigSettings(); 128 } 129 130 /** Returns the object with the settings used for calls to updateRecommenderConfig. */ 131 public UnaryCallSettings<UpdateRecommenderConfigRequest, RecommenderConfig> updateRecommenderConfigSettings()132 updateRecommenderConfigSettings() { 133 return ((RecommenderStubSettings) getStubSettings()).updateRecommenderConfigSettings(); 134 } 135 136 /** Returns the object with the settings used for calls to getInsightTypeConfig. */ 137 public UnaryCallSettings<GetInsightTypeConfigRequest, InsightTypeConfig> getInsightTypeConfigSettings()138 getInsightTypeConfigSettings() { 139 return ((RecommenderStubSettings) getStubSettings()).getInsightTypeConfigSettings(); 140 } 141 142 /** Returns the object with the settings used for calls to updateInsightTypeConfig. */ 143 public UnaryCallSettings<UpdateInsightTypeConfigRequest, InsightTypeConfig> updateInsightTypeConfigSettings()144 updateInsightTypeConfigSettings() { 145 return ((RecommenderStubSettings) getStubSettings()).updateInsightTypeConfigSettings(); 146 } 147 create(RecommenderStubSettings stub)148 public static final RecommenderSettings create(RecommenderStubSettings stub) throws IOException { 149 return new RecommenderSettings.Builder(stub.toBuilder()).build(); 150 } 151 152 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()153 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 154 return RecommenderStubSettings.defaultExecutorProviderBuilder(); 155 } 156 157 /** Returns the default service endpoint. */ getDefaultEndpoint()158 public static String getDefaultEndpoint() { 159 return RecommenderStubSettings.getDefaultEndpoint(); 160 } 161 162 /** Returns the default service scopes. */ getDefaultServiceScopes()163 public static List<String> getDefaultServiceScopes() { 164 return RecommenderStubSettings.getDefaultServiceScopes(); 165 } 166 167 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()168 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 169 return RecommenderStubSettings.defaultCredentialsProviderBuilder(); 170 } 171 172 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()173 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 174 return RecommenderStubSettings.defaultGrpcTransportProviderBuilder(); 175 } 176 177 /** Returns a builder for the default REST ChannelProvider for this service. */ 178 @BetaApi 179 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()180 defaultHttpJsonTransportProviderBuilder() { 181 return RecommenderStubSettings.defaultHttpJsonTransportProviderBuilder(); 182 } 183 defaultTransportChannelProvider()184 public static TransportChannelProvider defaultTransportChannelProvider() { 185 return RecommenderStubSettings.defaultTransportChannelProvider(); 186 } 187 188 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()189 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 190 return RecommenderStubSettings.defaultApiClientHeaderProviderBuilder(); 191 } 192 193 /** Returns a new gRPC builder for this class. */ newBuilder()194 public static Builder newBuilder() { 195 return Builder.createDefault(); 196 } 197 198 /** Returns a new REST builder for this class. */ 199 @BetaApi newHttpJsonBuilder()200 public static Builder newHttpJsonBuilder() { 201 return Builder.createHttpJsonDefault(); 202 } 203 204 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)205 public static Builder newBuilder(ClientContext clientContext) { 206 return new Builder(clientContext); 207 } 208 209 /** Returns a builder containing all the values of this settings class. */ toBuilder()210 public Builder toBuilder() { 211 return new Builder(this); 212 } 213 RecommenderSettings(Builder settingsBuilder)214 protected RecommenderSettings(Builder settingsBuilder) throws IOException { 215 super(settingsBuilder); 216 } 217 218 /** Builder for RecommenderSettings. */ 219 public static class Builder extends ClientSettings.Builder<RecommenderSettings, Builder> { 220 Builder()221 protected Builder() throws IOException { 222 this(((ClientContext) null)); 223 } 224 Builder(ClientContext clientContext)225 protected Builder(ClientContext clientContext) { 226 super(RecommenderStubSettings.newBuilder(clientContext)); 227 } 228 Builder(RecommenderSettings settings)229 protected Builder(RecommenderSettings settings) { 230 super(settings.getStubSettings().toBuilder()); 231 } 232 Builder(RecommenderStubSettings.Builder stubSettings)233 protected Builder(RecommenderStubSettings.Builder stubSettings) { 234 super(stubSettings); 235 } 236 createDefault()237 private static Builder createDefault() { 238 return new Builder(RecommenderStubSettings.newBuilder()); 239 } 240 241 @BetaApi createHttpJsonDefault()242 private static Builder createHttpJsonDefault() { 243 return new Builder(RecommenderStubSettings.newHttpJsonBuilder()); 244 } 245 getStubSettingsBuilder()246 public RecommenderStubSettings.Builder getStubSettingsBuilder() { 247 return ((RecommenderStubSettings.Builder) getStubSettings()); 248 } 249 250 /** 251 * Applies the given settings updater function to all of the unary API methods in this service. 252 * 253 * <p>Note: This method does not support applying settings to streaming methods. 254 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)255 public Builder applyToAllUnaryMethods( 256 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 257 super.applyToAllUnaryMethods( 258 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 259 return this; 260 } 261 262 /** Returns the builder for the settings used for calls to listInsights. */ 263 public PagedCallSettings.Builder< 264 ListInsightsRequest, ListInsightsResponse, ListInsightsPagedResponse> listInsightsSettings()265 listInsightsSettings() { 266 return getStubSettingsBuilder().listInsightsSettings(); 267 } 268 269 /** Returns the builder for the settings used for calls to getInsight. */ getInsightSettings()270 public UnaryCallSettings.Builder<GetInsightRequest, Insight> getInsightSettings() { 271 return getStubSettingsBuilder().getInsightSettings(); 272 } 273 274 /** Returns the builder for the settings used for calls to markInsightAccepted. */ 275 public UnaryCallSettings.Builder<MarkInsightAcceptedRequest, Insight> markInsightAcceptedSettings()276 markInsightAcceptedSettings() { 277 return getStubSettingsBuilder().markInsightAcceptedSettings(); 278 } 279 280 /** Returns the builder for the settings used for calls to listRecommendations. */ 281 public PagedCallSettings.Builder< 282 ListRecommendationsRequest, 283 ListRecommendationsResponse, 284 ListRecommendationsPagedResponse> listRecommendationsSettings()285 listRecommendationsSettings() { 286 return getStubSettingsBuilder().listRecommendationsSettings(); 287 } 288 289 /** Returns the builder for the settings used for calls to getRecommendation. */ 290 public UnaryCallSettings.Builder<GetRecommendationRequest, Recommendation> getRecommendationSettings()291 getRecommendationSettings() { 292 return getStubSettingsBuilder().getRecommendationSettings(); 293 } 294 295 /** Returns the builder for the settings used for calls to markRecommendationClaimed. */ 296 public UnaryCallSettings.Builder<MarkRecommendationClaimedRequest, Recommendation> markRecommendationClaimedSettings()297 markRecommendationClaimedSettings() { 298 return getStubSettingsBuilder().markRecommendationClaimedSettings(); 299 } 300 301 /** Returns the builder for the settings used for calls to markRecommendationSucceeded. */ 302 public UnaryCallSettings.Builder<MarkRecommendationSucceededRequest, Recommendation> markRecommendationSucceededSettings()303 markRecommendationSucceededSettings() { 304 return getStubSettingsBuilder().markRecommendationSucceededSettings(); 305 } 306 307 /** Returns the builder for the settings used for calls to markRecommendationFailed. */ 308 public UnaryCallSettings.Builder<MarkRecommendationFailedRequest, Recommendation> markRecommendationFailedSettings()309 markRecommendationFailedSettings() { 310 return getStubSettingsBuilder().markRecommendationFailedSettings(); 311 } 312 313 /** Returns the builder for the settings used for calls to getRecommenderConfig. */ 314 public UnaryCallSettings.Builder<GetRecommenderConfigRequest, RecommenderConfig> getRecommenderConfigSettings()315 getRecommenderConfigSettings() { 316 return getStubSettingsBuilder().getRecommenderConfigSettings(); 317 } 318 319 /** Returns the builder for the settings used for calls to updateRecommenderConfig. */ 320 public UnaryCallSettings.Builder<UpdateRecommenderConfigRequest, RecommenderConfig> updateRecommenderConfigSettings()321 updateRecommenderConfigSettings() { 322 return getStubSettingsBuilder().updateRecommenderConfigSettings(); 323 } 324 325 /** Returns the builder for the settings used for calls to getInsightTypeConfig. */ 326 public UnaryCallSettings.Builder<GetInsightTypeConfigRequest, InsightTypeConfig> getInsightTypeConfigSettings()327 getInsightTypeConfigSettings() { 328 return getStubSettingsBuilder().getInsightTypeConfigSettings(); 329 } 330 331 /** Returns the builder for the settings used for calls to updateInsightTypeConfig. */ 332 public UnaryCallSettings.Builder<UpdateInsightTypeConfigRequest, InsightTypeConfig> updateInsightTypeConfigSettings()333 updateInsightTypeConfigSettings() { 334 return getStubSettingsBuilder().updateInsightTypeConfigSettings(); 335 } 336 337 @Override build()338 public RecommenderSettings build() throws IOException { 339 return new RecommenderSettings(this); 340 } 341 } 342 } 343