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 com.google.api.HttpBody; 20 import com.google.api.core.ApiFunction; 21 import com.google.api.core.BetaApi; 22 import com.google.api.gax.core.GoogleCredentialsProvider; 23 import com.google.api.gax.core.InstantiatingExecutorProvider; 24 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; 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.TransportChannelProvider; 31 import com.google.api.gax.rpc.UnaryCallSettings; 32 import com.google.cloud.retail.v2.stub.UserEventServiceStubSettings; 33 import com.google.longrunning.Operation; 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 UserEventServiceClient}. 41 * 42 * <p>The default instance has everything set to sensible defaults: 43 * 44 * <ul> 45 * <li>The default service address (retail.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 writeUserEvent 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 * UserEventServiceSettings.Builder userEventServiceSettingsBuilder = 62 * UserEventServiceSettings.newBuilder(); 63 * userEventServiceSettingsBuilder 64 * .writeUserEventSettings() 65 * .setRetrySettings( 66 * userEventServiceSettingsBuilder 67 * .writeUserEventSettings() 68 * .getRetrySettings() 69 * .toBuilder() 70 * .setTotalTimeout(Duration.ofSeconds(30)) 71 * .build()); 72 * UserEventServiceSettings userEventServiceSettings = userEventServiceSettingsBuilder.build(); 73 * }</pre> 74 */ 75 @Generated("by gapic-generator-java") 76 public class UserEventServiceSettings extends ClientSettings<UserEventServiceSettings> { 77 78 /** Returns the object with the settings used for calls to writeUserEvent. */ writeUserEventSettings()79 public UnaryCallSettings<WriteUserEventRequest, UserEvent> writeUserEventSettings() { 80 return ((UserEventServiceStubSettings) getStubSettings()).writeUserEventSettings(); 81 } 82 83 /** Returns the object with the settings used for calls to collectUserEvent. */ collectUserEventSettings()84 public UnaryCallSettings<CollectUserEventRequest, HttpBody> collectUserEventSettings() { 85 return ((UserEventServiceStubSettings) getStubSettings()).collectUserEventSettings(); 86 } 87 88 /** Returns the object with the settings used for calls to purgeUserEvents. */ purgeUserEventsSettings()89 public UnaryCallSettings<PurgeUserEventsRequest, Operation> purgeUserEventsSettings() { 90 return ((UserEventServiceStubSettings) getStubSettings()).purgeUserEventsSettings(); 91 } 92 93 /** Returns the object with the settings used for calls to purgeUserEvents. */ 94 public OperationCallSettings<PurgeUserEventsRequest, PurgeUserEventsResponse, PurgeMetadata> purgeUserEventsOperationSettings()95 purgeUserEventsOperationSettings() { 96 return ((UserEventServiceStubSettings) getStubSettings()).purgeUserEventsOperationSettings(); 97 } 98 99 /** Returns the object with the settings used for calls to importUserEvents. */ importUserEventsSettings()100 public UnaryCallSettings<ImportUserEventsRequest, Operation> importUserEventsSettings() { 101 return ((UserEventServiceStubSettings) getStubSettings()).importUserEventsSettings(); 102 } 103 104 /** Returns the object with the settings used for calls to importUserEvents. */ 105 public OperationCallSettings<ImportUserEventsRequest, ImportUserEventsResponse, ImportMetadata> importUserEventsOperationSettings()106 importUserEventsOperationSettings() { 107 return ((UserEventServiceStubSettings) getStubSettings()).importUserEventsOperationSettings(); 108 } 109 110 /** Returns the object with the settings used for calls to rejoinUserEvents. */ rejoinUserEventsSettings()111 public UnaryCallSettings<RejoinUserEventsRequest, Operation> rejoinUserEventsSettings() { 112 return ((UserEventServiceStubSettings) getStubSettings()).rejoinUserEventsSettings(); 113 } 114 115 /** Returns the object with the settings used for calls to rejoinUserEvents. */ 116 public OperationCallSettings< 117 RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> rejoinUserEventsOperationSettings()118 rejoinUserEventsOperationSettings() { 119 return ((UserEventServiceStubSettings) getStubSettings()).rejoinUserEventsOperationSettings(); 120 } 121 create(UserEventServiceStubSettings stub)122 public static final UserEventServiceSettings create(UserEventServiceStubSettings stub) 123 throws IOException { 124 return new UserEventServiceSettings.Builder(stub.toBuilder()).build(); 125 } 126 127 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()128 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 129 return UserEventServiceStubSettings.defaultExecutorProviderBuilder(); 130 } 131 132 /** Returns the default service endpoint. */ getDefaultEndpoint()133 public static String getDefaultEndpoint() { 134 return UserEventServiceStubSettings.getDefaultEndpoint(); 135 } 136 137 /** Returns the default service scopes. */ getDefaultServiceScopes()138 public static List<String> getDefaultServiceScopes() { 139 return UserEventServiceStubSettings.getDefaultServiceScopes(); 140 } 141 142 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()143 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 144 return UserEventServiceStubSettings.defaultCredentialsProviderBuilder(); 145 } 146 147 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()148 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 149 return UserEventServiceStubSettings.defaultGrpcTransportProviderBuilder(); 150 } 151 152 /** Returns a builder for the default REST ChannelProvider for this service. */ 153 @BetaApi 154 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()155 defaultHttpJsonTransportProviderBuilder() { 156 return UserEventServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); 157 } 158 defaultTransportChannelProvider()159 public static TransportChannelProvider defaultTransportChannelProvider() { 160 return UserEventServiceStubSettings.defaultTransportChannelProvider(); 161 } 162 163 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()164 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 165 return UserEventServiceStubSettings.defaultApiClientHeaderProviderBuilder(); 166 } 167 168 /** Returns a new gRPC builder for this class. */ newBuilder()169 public static Builder newBuilder() { 170 return Builder.createDefault(); 171 } 172 173 /** Returns a new REST builder for this class. */ 174 @BetaApi newHttpJsonBuilder()175 public static Builder newHttpJsonBuilder() { 176 return Builder.createHttpJsonDefault(); 177 } 178 179 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)180 public static Builder newBuilder(ClientContext clientContext) { 181 return new Builder(clientContext); 182 } 183 184 /** Returns a builder containing all the values of this settings class. */ toBuilder()185 public Builder toBuilder() { 186 return new Builder(this); 187 } 188 UserEventServiceSettings(Builder settingsBuilder)189 protected UserEventServiceSettings(Builder settingsBuilder) throws IOException { 190 super(settingsBuilder); 191 } 192 193 /** Builder for UserEventServiceSettings. */ 194 public static class Builder extends ClientSettings.Builder<UserEventServiceSettings, Builder> { 195 Builder()196 protected Builder() throws IOException { 197 this(((ClientContext) null)); 198 } 199 Builder(ClientContext clientContext)200 protected Builder(ClientContext clientContext) { 201 super(UserEventServiceStubSettings.newBuilder(clientContext)); 202 } 203 Builder(UserEventServiceSettings settings)204 protected Builder(UserEventServiceSettings settings) { 205 super(settings.getStubSettings().toBuilder()); 206 } 207 Builder(UserEventServiceStubSettings.Builder stubSettings)208 protected Builder(UserEventServiceStubSettings.Builder stubSettings) { 209 super(stubSettings); 210 } 211 createDefault()212 private static Builder createDefault() { 213 return new Builder(UserEventServiceStubSettings.newBuilder()); 214 } 215 216 @BetaApi createHttpJsonDefault()217 private static Builder createHttpJsonDefault() { 218 return new Builder(UserEventServiceStubSettings.newHttpJsonBuilder()); 219 } 220 getStubSettingsBuilder()221 public UserEventServiceStubSettings.Builder getStubSettingsBuilder() { 222 return ((UserEventServiceStubSettings.Builder) getStubSettings()); 223 } 224 225 /** 226 * Applies the given settings updater function to all of the unary API methods in this service. 227 * 228 * <p>Note: This method does not support applying settings to streaming methods. 229 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)230 public Builder applyToAllUnaryMethods( 231 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 232 super.applyToAllUnaryMethods( 233 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 234 return this; 235 } 236 237 /** Returns the builder for the settings used for calls to writeUserEvent. */ writeUserEventSettings()238 public UnaryCallSettings.Builder<WriteUserEventRequest, UserEvent> writeUserEventSettings() { 239 return getStubSettingsBuilder().writeUserEventSettings(); 240 } 241 242 /** Returns the builder for the settings used for calls to collectUserEvent. */ collectUserEventSettings()243 public UnaryCallSettings.Builder<CollectUserEventRequest, HttpBody> collectUserEventSettings() { 244 return getStubSettingsBuilder().collectUserEventSettings(); 245 } 246 247 /** Returns the builder for the settings used for calls to purgeUserEvents. */ purgeUserEventsSettings()248 public UnaryCallSettings.Builder<PurgeUserEventsRequest, Operation> purgeUserEventsSettings() { 249 return getStubSettingsBuilder().purgeUserEventsSettings(); 250 } 251 252 /** Returns the builder for the settings used for calls to purgeUserEvents. */ 253 public OperationCallSettings.Builder< 254 PurgeUserEventsRequest, PurgeUserEventsResponse, PurgeMetadata> purgeUserEventsOperationSettings()255 purgeUserEventsOperationSettings() { 256 return getStubSettingsBuilder().purgeUserEventsOperationSettings(); 257 } 258 259 /** Returns the builder for the settings used for calls to importUserEvents. */ 260 public UnaryCallSettings.Builder<ImportUserEventsRequest, Operation> importUserEventsSettings()261 importUserEventsSettings() { 262 return getStubSettingsBuilder().importUserEventsSettings(); 263 } 264 265 /** Returns the builder for the settings used for calls to importUserEvents. */ 266 public OperationCallSettings.Builder< 267 ImportUserEventsRequest, ImportUserEventsResponse, ImportMetadata> importUserEventsOperationSettings()268 importUserEventsOperationSettings() { 269 return getStubSettingsBuilder().importUserEventsOperationSettings(); 270 } 271 272 /** Returns the builder for the settings used for calls to rejoinUserEvents. */ 273 public UnaryCallSettings.Builder<RejoinUserEventsRequest, Operation> rejoinUserEventsSettings()274 rejoinUserEventsSettings() { 275 return getStubSettingsBuilder().rejoinUserEventsSettings(); 276 } 277 278 /** Returns the builder for the settings used for calls to rejoinUserEvents. */ 279 public OperationCallSettings.Builder< 280 RejoinUserEventsRequest, RejoinUserEventsResponse, RejoinUserEventsMetadata> rejoinUserEventsOperationSettings()281 rejoinUserEventsOperationSettings() { 282 return getStubSettingsBuilder().rejoinUserEventsOperationSettings(); 283 } 284 285 @Override build()286 public UserEventServiceSettings build() throws IOException { 287 return new UserEventServiceSettings(this); 288 } 289 } 290 } 291