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.aiplatform.v1beta1; 18 19 import static com.google.cloud.aiplatform.v1beta1.IndexServiceClient.ListIndexesPagedResponse; 20 import static com.google.cloud.aiplatform.v1beta1.IndexServiceClient.ListLocationsPagedResponse; 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.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.OperationCallSettings; 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.aiplatform.v1beta1.stub.IndexServiceStubSettings; 35 import com.google.cloud.location.GetLocationRequest; 36 import com.google.cloud.location.ListLocationsRequest; 37 import com.google.cloud.location.ListLocationsResponse; 38 import com.google.cloud.location.Location; 39 import com.google.iam.v1.GetIamPolicyRequest; 40 import com.google.iam.v1.Policy; 41 import com.google.iam.v1.SetIamPolicyRequest; 42 import com.google.iam.v1.TestIamPermissionsRequest; 43 import com.google.iam.v1.TestIamPermissionsResponse; 44 import com.google.longrunning.Operation; 45 import com.google.protobuf.Empty; 46 import java.io.IOException; 47 import java.util.List; 48 import javax.annotation.Generated; 49 50 // AUTO-GENERATED DOCUMENTATION AND CLASS. 51 /** 52 * Settings class to configure an instance of {@link IndexServiceClient}. 53 * 54 * <p>The default instance has everything set to sensible defaults: 55 * 56 * <ul> 57 * <li>The default service address (aiplatform.googleapis.com) and default port (443) are used. 58 * <li>Credentials are acquired automatically through Application Default Credentials. 59 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 60 * </ul> 61 * 62 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 63 * build() is called, the tree of builders is called to create the complete settings object. 64 * 65 * <p>For example, to set the total timeout of getIndex to 30 seconds: 66 * 67 * <pre>{@code 68 * // This snippet has been automatically generated and should be regarded as a code template only. 69 * // It will require modifications to work: 70 * // - It may require correct/in-range values for request initialization. 71 * // - It may require specifying regional endpoints when creating the service client as shown in 72 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 73 * IndexServiceSettings.Builder indexServiceSettingsBuilder = IndexServiceSettings.newBuilder(); 74 * indexServiceSettingsBuilder 75 * .getIndexSettings() 76 * .setRetrySettings( 77 * indexServiceSettingsBuilder 78 * .getIndexSettings() 79 * .getRetrySettings() 80 * .toBuilder() 81 * .setTotalTimeout(Duration.ofSeconds(30)) 82 * .build()); 83 * IndexServiceSettings indexServiceSettings = indexServiceSettingsBuilder.build(); 84 * }</pre> 85 */ 86 @BetaApi 87 @Generated("by gapic-generator-java") 88 public class IndexServiceSettings extends ClientSettings<IndexServiceSettings> { 89 90 /** Returns the object with the settings used for calls to createIndex. */ createIndexSettings()91 public UnaryCallSettings<CreateIndexRequest, Operation> createIndexSettings() { 92 return ((IndexServiceStubSettings) getStubSettings()).createIndexSettings(); 93 } 94 95 /** Returns the object with the settings used for calls to createIndex. */ 96 public OperationCallSettings<CreateIndexRequest, Index, CreateIndexOperationMetadata> createIndexOperationSettings()97 createIndexOperationSettings() { 98 return ((IndexServiceStubSettings) getStubSettings()).createIndexOperationSettings(); 99 } 100 101 /** Returns the object with the settings used for calls to getIndex. */ getIndexSettings()102 public UnaryCallSettings<GetIndexRequest, Index> getIndexSettings() { 103 return ((IndexServiceStubSettings) getStubSettings()).getIndexSettings(); 104 } 105 106 /** Returns the object with the settings used for calls to listIndexes. */ 107 public PagedCallSettings<ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> listIndexesSettings()108 listIndexesSettings() { 109 return ((IndexServiceStubSettings) getStubSettings()).listIndexesSettings(); 110 } 111 112 /** Returns the object with the settings used for calls to updateIndex. */ updateIndexSettings()113 public UnaryCallSettings<UpdateIndexRequest, Operation> updateIndexSettings() { 114 return ((IndexServiceStubSettings) getStubSettings()).updateIndexSettings(); 115 } 116 117 /** Returns the object with the settings used for calls to updateIndex. */ 118 public OperationCallSettings<UpdateIndexRequest, Index, UpdateIndexOperationMetadata> updateIndexOperationSettings()119 updateIndexOperationSettings() { 120 return ((IndexServiceStubSettings) getStubSettings()).updateIndexOperationSettings(); 121 } 122 123 /** Returns the object with the settings used for calls to deleteIndex. */ deleteIndexSettings()124 public UnaryCallSettings<DeleteIndexRequest, Operation> deleteIndexSettings() { 125 return ((IndexServiceStubSettings) getStubSettings()).deleteIndexSettings(); 126 } 127 128 /** Returns the object with the settings used for calls to deleteIndex. */ 129 public OperationCallSettings<DeleteIndexRequest, Empty, DeleteOperationMetadata> deleteIndexOperationSettings()130 deleteIndexOperationSettings() { 131 return ((IndexServiceStubSettings) getStubSettings()).deleteIndexOperationSettings(); 132 } 133 134 /** Returns the object with the settings used for calls to upsertDatapoints. */ 135 public UnaryCallSettings<UpsertDatapointsRequest, UpsertDatapointsResponse> upsertDatapointsSettings()136 upsertDatapointsSettings() { 137 return ((IndexServiceStubSettings) getStubSettings()).upsertDatapointsSettings(); 138 } 139 140 /** Returns the object with the settings used for calls to removeDatapoints. */ 141 public UnaryCallSettings<RemoveDatapointsRequest, RemoveDatapointsResponse> removeDatapointsSettings()142 removeDatapointsSettings() { 143 return ((IndexServiceStubSettings) getStubSettings()).removeDatapointsSettings(); 144 } 145 146 /** Returns the object with the settings used for calls to listLocations. */ 147 public PagedCallSettings<ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()148 listLocationsSettings() { 149 return ((IndexServiceStubSettings) getStubSettings()).listLocationsSettings(); 150 } 151 152 /** Returns the object with the settings used for calls to getLocation. */ getLocationSettings()153 public UnaryCallSettings<GetLocationRequest, Location> getLocationSettings() { 154 return ((IndexServiceStubSettings) getStubSettings()).getLocationSettings(); 155 } 156 157 /** Returns the object with the settings used for calls to setIamPolicy. */ setIamPolicySettings()158 public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() { 159 return ((IndexServiceStubSettings) getStubSettings()).setIamPolicySettings(); 160 } 161 162 /** Returns the object with the settings used for calls to getIamPolicy. */ getIamPolicySettings()163 public UnaryCallSettings<GetIamPolicyRequest, Policy> getIamPolicySettings() { 164 return ((IndexServiceStubSettings) getStubSettings()).getIamPolicySettings(); 165 } 166 167 /** Returns the object with the settings used for calls to testIamPermissions. */ 168 public UnaryCallSettings<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()169 testIamPermissionsSettings() { 170 return ((IndexServiceStubSettings) getStubSettings()).testIamPermissionsSettings(); 171 } 172 create(IndexServiceStubSettings stub)173 public static final IndexServiceSettings create(IndexServiceStubSettings stub) 174 throws IOException { 175 return new IndexServiceSettings.Builder(stub.toBuilder()).build(); 176 } 177 178 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()179 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 180 return IndexServiceStubSettings.defaultExecutorProviderBuilder(); 181 } 182 183 /** Returns the default service endpoint. */ getDefaultEndpoint()184 public static String getDefaultEndpoint() { 185 return IndexServiceStubSettings.getDefaultEndpoint(); 186 } 187 188 /** Returns the default service scopes. */ getDefaultServiceScopes()189 public static List<String> getDefaultServiceScopes() { 190 return IndexServiceStubSettings.getDefaultServiceScopes(); 191 } 192 193 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()194 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 195 return IndexServiceStubSettings.defaultCredentialsProviderBuilder(); 196 } 197 198 /** Returns a builder for the default ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()199 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 200 return IndexServiceStubSettings.defaultGrpcTransportProviderBuilder(); 201 } 202 defaultTransportChannelProvider()203 public static TransportChannelProvider defaultTransportChannelProvider() { 204 return IndexServiceStubSettings.defaultTransportChannelProvider(); 205 } 206 207 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()208 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 209 return IndexServiceStubSettings.defaultApiClientHeaderProviderBuilder(); 210 } 211 212 /** Returns a new builder for this class. */ newBuilder()213 public static Builder newBuilder() { 214 return Builder.createDefault(); 215 } 216 217 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)218 public static Builder newBuilder(ClientContext clientContext) { 219 return new Builder(clientContext); 220 } 221 222 /** Returns a builder containing all the values of this settings class. */ toBuilder()223 public Builder toBuilder() { 224 return new Builder(this); 225 } 226 IndexServiceSettings(Builder settingsBuilder)227 protected IndexServiceSettings(Builder settingsBuilder) throws IOException { 228 super(settingsBuilder); 229 } 230 231 /** Builder for IndexServiceSettings. */ 232 public static class Builder extends ClientSettings.Builder<IndexServiceSettings, Builder> { 233 Builder()234 protected Builder() throws IOException { 235 this(((ClientContext) null)); 236 } 237 Builder(ClientContext clientContext)238 protected Builder(ClientContext clientContext) { 239 super(IndexServiceStubSettings.newBuilder(clientContext)); 240 } 241 Builder(IndexServiceSettings settings)242 protected Builder(IndexServiceSettings settings) { 243 super(settings.getStubSettings().toBuilder()); 244 } 245 Builder(IndexServiceStubSettings.Builder stubSettings)246 protected Builder(IndexServiceStubSettings.Builder stubSettings) { 247 super(stubSettings); 248 } 249 createDefault()250 private static Builder createDefault() { 251 return new Builder(IndexServiceStubSettings.newBuilder()); 252 } 253 getStubSettingsBuilder()254 public IndexServiceStubSettings.Builder getStubSettingsBuilder() { 255 return ((IndexServiceStubSettings.Builder) getStubSettings()); 256 } 257 258 /** 259 * Applies the given settings updater function to all of the unary API methods in this service. 260 * 261 * <p>Note: This method does not support applying settings to streaming methods. 262 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)263 public Builder applyToAllUnaryMethods( 264 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 265 super.applyToAllUnaryMethods( 266 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 267 return this; 268 } 269 270 /** Returns the builder for the settings used for calls to createIndex. */ createIndexSettings()271 public UnaryCallSettings.Builder<CreateIndexRequest, Operation> createIndexSettings() { 272 return getStubSettingsBuilder().createIndexSettings(); 273 } 274 275 /** Returns the builder for the settings used for calls to createIndex. */ 276 public OperationCallSettings.Builder<CreateIndexRequest, Index, CreateIndexOperationMetadata> createIndexOperationSettings()277 createIndexOperationSettings() { 278 return getStubSettingsBuilder().createIndexOperationSettings(); 279 } 280 281 /** Returns the builder for the settings used for calls to getIndex. */ getIndexSettings()282 public UnaryCallSettings.Builder<GetIndexRequest, Index> getIndexSettings() { 283 return getStubSettingsBuilder().getIndexSettings(); 284 } 285 286 /** Returns the builder for the settings used for calls to listIndexes. */ 287 public PagedCallSettings.Builder< 288 ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> listIndexesSettings()289 listIndexesSettings() { 290 return getStubSettingsBuilder().listIndexesSettings(); 291 } 292 293 /** Returns the builder for the settings used for calls to updateIndex. */ updateIndexSettings()294 public UnaryCallSettings.Builder<UpdateIndexRequest, Operation> updateIndexSettings() { 295 return getStubSettingsBuilder().updateIndexSettings(); 296 } 297 298 /** Returns the builder for the settings used for calls to updateIndex. */ 299 public OperationCallSettings.Builder<UpdateIndexRequest, Index, UpdateIndexOperationMetadata> updateIndexOperationSettings()300 updateIndexOperationSettings() { 301 return getStubSettingsBuilder().updateIndexOperationSettings(); 302 } 303 304 /** Returns the builder for the settings used for calls to deleteIndex. */ deleteIndexSettings()305 public UnaryCallSettings.Builder<DeleteIndexRequest, Operation> deleteIndexSettings() { 306 return getStubSettingsBuilder().deleteIndexSettings(); 307 } 308 309 /** Returns the builder for the settings used for calls to deleteIndex. */ 310 public OperationCallSettings.Builder<DeleteIndexRequest, Empty, DeleteOperationMetadata> deleteIndexOperationSettings()311 deleteIndexOperationSettings() { 312 return getStubSettingsBuilder().deleteIndexOperationSettings(); 313 } 314 315 /** Returns the builder for the settings used for calls to upsertDatapoints. */ 316 public UnaryCallSettings.Builder<UpsertDatapointsRequest, UpsertDatapointsResponse> upsertDatapointsSettings()317 upsertDatapointsSettings() { 318 return getStubSettingsBuilder().upsertDatapointsSettings(); 319 } 320 321 /** Returns the builder for the settings used for calls to removeDatapoints. */ 322 public UnaryCallSettings.Builder<RemoveDatapointsRequest, RemoveDatapointsResponse> removeDatapointsSettings()323 removeDatapointsSettings() { 324 return getStubSettingsBuilder().removeDatapointsSettings(); 325 } 326 327 /** Returns the builder for the settings used for calls to listLocations. */ 328 public PagedCallSettings.Builder< 329 ListLocationsRequest, ListLocationsResponse, ListLocationsPagedResponse> listLocationsSettings()330 listLocationsSettings() { 331 return getStubSettingsBuilder().listLocationsSettings(); 332 } 333 334 /** Returns the builder for the settings used for calls to getLocation. */ getLocationSettings()335 public UnaryCallSettings.Builder<GetLocationRequest, Location> getLocationSettings() { 336 return getStubSettingsBuilder().getLocationSettings(); 337 } 338 339 /** Returns the builder for the settings used for calls to setIamPolicy. */ setIamPolicySettings()340 public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettings() { 341 return getStubSettingsBuilder().setIamPolicySettings(); 342 } 343 344 /** Returns the builder for the settings used for calls to getIamPolicy. */ getIamPolicySettings()345 public UnaryCallSettings.Builder<GetIamPolicyRequest, Policy> getIamPolicySettings() { 346 return getStubSettingsBuilder().getIamPolicySettings(); 347 } 348 349 /** Returns the builder for the settings used for calls to testIamPermissions. */ 350 public UnaryCallSettings.Builder<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()351 testIamPermissionsSettings() { 352 return getStubSettingsBuilder().testIamPermissionsSettings(); 353 } 354 355 @Override build()356 public IndexServiceSettings build() throws IOException { 357 return new IndexServiceSettings(this); 358 } 359 } 360 } 361