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.talent.v4beta1; 18 19 import com.google.api.core.ApiFunction; 20 import com.google.api.core.BetaApi; 21 import com.google.api.gax.core.GoogleCredentialsProvider; 22 import com.google.api.gax.core.InstantiatingExecutorProvider; 23 import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; 24 import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; 25 import com.google.api.gax.rpc.ApiClientHeaderProvider; 26 import com.google.api.gax.rpc.ClientContext; 27 import com.google.api.gax.rpc.ClientSettings; 28 import com.google.api.gax.rpc.TransportChannelProvider; 29 import com.google.api.gax.rpc.UnaryCallSettings; 30 import com.google.cloud.talent.v4beta1.stub.CompletionStubSettings; 31 import java.io.IOException; 32 import java.util.List; 33 import javax.annotation.Generated; 34 35 // AUTO-GENERATED DOCUMENTATION AND CLASS. 36 /** 37 * Settings class to configure an instance of {@link CompletionClient}. 38 * 39 * <p>The default instance has everything set to sensible defaults: 40 * 41 * <ul> 42 * <li>The default service address (jobs.googleapis.com) and default port (443) are used. 43 * <li>Credentials are acquired automatically through Application Default Credentials. 44 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 45 * </ul> 46 * 47 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 48 * build() is called, the tree of builders is called to create the complete settings object. 49 * 50 * <p>For example, to set the total timeout of completeQuery to 30 seconds: 51 * 52 * <pre>{@code 53 * // This snippet has been automatically generated and should be regarded as a code template only. 54 * // It will require modifications to work: 55 * // - It may require correct/in-range values for request initialization. 56 * // - It may require specifying regional endpoints when creating the service client as shown in 57 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 58 * CompletionSettings.Builder completionSettingsBuilder = CompletionSettings.newBuilder(); 59 * completionSettingsBuilder 60 * .completeQuerySettings() 61 * .setRetrySettings( 62 * completionSettingsBuilder 63 * .completeQuerySettings() 64 * .getRetrySettings() 65 * .toBuilder() 66 * .setTotalTimeout(Duration.ofSeconds(30)) 67 * .build()); 68 * CompletionSettings completionSettings = completionSettingsBuilder.build(); 69 * }</pre> 70 */ 71 @BetaApi 72 @Generated("by gapic-generator-java") 73 public class CompletionSettings extends ClientSettings<CompletionSettings> { 74 75 /** Returns the object with the settings used for calls to completeQuery. */ completeQuerySettings()76 public UnaryCallSettings<CompleteQueryRequest, CompleteQueryResponse> completeQuerySettings() { 77 return ((CompletionStubSettings) getStubSettings()).completeQuerySettings(); 78 } 79 create(CompletionStubSettings stub)80 public static final CompletionSettings create(CompletionStubSettings stub) throws IOException { 81 return new CompletionSettings.Builder(stub.toBuilder()).build(); 82 } 83 84 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()85 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 86 return CompletionStubSettings.defaultExecutorProviderBuilder(); 87 } 88 89 /** Returns the default service endpoint. */ getDefaultEndpoint()90 public static String getDefaultEndpoint() { 91 return CompletionStubSettings.getDefaultEndpoint(); 92 } 93 94 /** Returns the default service scopes. */ getDefaultServiceScopes()95 public static List<String> getDefaultServiceScopes() { 96 return CompletionStubSettings.getDefaultServiceScopes(); 97 } 98 99 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()100 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 101 return CompletionStubSettings.defaultCredentialsProviderBuilder(); 102 } 103 104 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()105 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 106 return CompletionStubSettings.defaultGrpcTransportProviderBuilder(); 107 } 108 109 /** Returns a builder for the default REST ChannelProvider for this service. */ 110 @BetaApi 111 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()112 defaultHttpJsonTransportProviderBuilder() { 113 return CompletionStubSettings.defaultHttpJsonTransportProviderBuilder(); 114 } 115 defaultTransportChannelProvider()116 public static TransportChannelProvider defaultTransportChannelProvider() { 117 return CompletionStubSettings.defaultTransportChannelProvider(); 118 } 119 120 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()121 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 122 return CompletionStubSettings.defaultApiClientHeaderProviderBuilder(); 123 } 124 125 /** Returns a new gRPC builder for this class. */ newBuilder()126 public static Builder newBuilder() { 127 return Builder.createDefault(); 128 } 129 130 /** Returns a new REST builder for this class. */ 131 @BetaApi newHttpJsonBuilder()132 public static Builder newHttpJsonBuilder() { 133 return Builder.createHttpJsonDefault(); 134 } 135 136 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)137 public static Builder newBuilder(ClientContext clientContext) { 138 return new Builder(clientContext); 139 } 140 141 /** Returns a builder containing all the values of this settings class. */ toBuilder()142 public Builder toBuilder() { 143 return new Builder(this); 144 } 145 CompletionSettings(Builder settingsBuilder)146 protected CompletionSettings(Builder settingsBuilder) throws IOException { 147 super(settingsBuilder); 148 } 149 150 /** Builder for CompletionSettings. */ 151 public static class Builder extends ClientSettings.Builder<CompletionSettings, Builder> { 152 Builder()153 protected Builder() throws IOException { 154 this(((ClientContext) null)); 155 } 156 Builder(ClientContext clientContext)157 protected Builder(ClientContext clientContext) { 158 super(CompletionStubSettings.newBuilder(clientContext)); 159 } 160 Builder(CompletionSettings settings)161 protected Builder(CompletionSettings settings) { 162 super(settings.getStubSettings().toBuilder()); 163 } 164 Builder(CompletionStubSettings.Builder stubSettings)165 protected Builder(CompletionStubSettings.Builder stubSettings) { 166 super(stubSettings); 167 } 168 createDefault()169 private static Builder createDefault() { 170 return new Builder(CompletionStubSettings.newBuilder()); 171 } 172 173 @BetaApi createHttpJsonDefault()174 private static Builder createHttpJsonDefault() { 175 return new Builder(CompletionStubSettings.newHttpJsonBuilder()); 176 } 177 getStubSettingsBuilder()178 public CompletionStubSettings.Builder getStubSettingsBuilder() { 179 return ((CompletionStubSettings.Builder) getStubSettings()); 180 } 181 182 /** 183 * Applies the given settings updater function to all of the unary API methods in this service. 184 * 185 * <p>Note: This method does not support applying settings to streaming methods. 186 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)187 public Builder applyToAllUnaryMethods( 188 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 189 super.applyToAllUnaryMethods( 190 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 191 return this; 192 } 193 194 /** Returns the builder for the settings used for calls to completeQuery. */ 195 public UnaryCallSettings.Builder<CompleteQueryRequest, CompleteQueryResponse> completeQuerySettings()196 completeQuerySettings() { 197 return getStubSettingsBuilder().completeQuerySettings(); 198 } 199 200 @Override build()201 public CompletionSettings build() throws IOException { 202 return new CompletionSettings(this); 203 } 204 } 205 } 206