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.compute.v1; 18 19 import static com.google.cloud.compute.v1.GlobalOperationsClient.AggregatedListPagedResponse; 20 import static com.google.cloud.compute.v1.GlobalOperationsClient.ListPagedResponse; 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.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.compute.v1.stub.GlobalOperationsStubSettings; 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 GlobalOperationsClient}. 41 * 42 * <p>The default instance has everything set to sensible defaults: 43 * 44 * <ul> 45 * <li>The default service address (compute.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 delete 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 * GlobalOperationsSettings.Builder globalOperationsSettingsBuilder = 62 * GlobalOperationsSettings.newBuilder(); 63 * globalOperationsSettingsBuilder 64 * .deleteSettings() 65 * .setRetrySettings( 66 * globalOperationsSettingsBuilder 67 * .deleteSettings() 68 * .getRetrySettings() 69 * .toBuilder() 70 * .setTotalTimeout(Duration.ofSeconds(30)) 71 * .build()); 72 * GlobalOperationsSettings globalOperationsSettings = globalOperationsSettingsBuilder.build(); 73 * }</pre> 74 */ 75 @Generated("by gapic-generator-java") 76 public class GlobalOperationsSettings extends ClientSettings<GlobalOperationsSettings> { 77 78 /** Returns the object with the settings used for calls to aggregatedList. */ 79 public PagedCallSettings< 80 AggregatedListGlobalOperationsRequest, 81 OperationAggregatedList, 82 AggregatedListPagedResponse> aggregatedListSettings()83 aggregatedListSettings() { 84 return ((GlobalOperationsStubSettings) getStubSettings()).aggregatedListSettings(); 85 } 86 87 /** Returns the object with the settings used for calls to delete. */ 88 public UnaryCallSettings<DeleteGlobalOperationRequest, DeleteGlobalOperationResponse> deleteSettings()89 deleteSettings() { 90 return ((GlobalOperationsStubSettings) getStubSettings()).deleteSettings(); 91 } 92 93 /** Returns the object with the settings used for calls to get. */ getSettings()94 public UnaryCallSettings<GetGlobalOperationRequest, Operation> getSettings() { 95 return ((GlobalOperationsStubSettings) getStubSettings()).getSettings(); 96 } 97 98 /** Returns the object with the settings used for calls to list. */ 99 public PagedCallSettings<ListGlobalOperationsRequest, OperationList, ListPagedResponse> listSettings()100 listSettings() { 101 return ((GlobalOperationsStubSettings) getStubSettings()).listSettings(); 102 } 103 104 /** Returns the object with the settings used for calls to wait. */ waitSettings()105 public UnaryCallSettings<WaitGlobalOperationRequest, Operation> waitSettings() { 106 return ((GlobalOperationsStubSettings) getStubSettings()).waitSettings(); 107 } 108 create(GlobalOperationsStubSettings stub)109 public static final GlobalOperationsSettings create(GlobalOperationsStubSettings stub) 110 throws IOException { 111 return new GlobalOperationsSettings.Builder(stub.toBuilder()).build(); 112 } 113 114 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()115 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 116 return GlobalOperationsStubSettings.defaultExecutorProviderBuilder(); 117 } 118 119 /** Returns the default service endpoint. */ getDefaultEndpoint()120 public static String getDefaultEndpoint() { 121 return GlobalOperationsStubSettings.getDefaultEndpoint(); 122 } 123 124 /** Returns the default service scopes. */ getDefaultServiceScopes()125 public static List<String> getDefaultServiceScopes() { 126 return GlobalOperationsStubSettings.getDefaultServiceScopes(); 127 } 128 129 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()130 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 131 return GlobalOperationsStubSettings.defaultCredentialsProviderBuilder(); 132 } 133 134 /** Returns a builder for the default ChannelProvider for this service. */ 135 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()136 defaultHttpJsonTransportProviderBuilder() { 137 return GlobalOperationsStubSettings.defaultHttpJsonTransportProviderBuilder(); 138 } 139 defaultTransportChannelProvider()140 public static TransportChannelProvider defaultTransportChannelProvider() { 141 return GlobalOperationsStubSettings.defaultTransportChannelProvider(); 142 } 143 144 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()145 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 146 return GlobalOperationsStubSettings.defaultApiClientHeaderProviderBuilder(); 147 } 148 149 /** Returns a new builder for this class. */ newBuilder()150 public static Builder newBuilder() { 151 return Builder.createDefault(); 152 } 153 154 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)155 public static Builder newBuilder(ClientContext clientContext) { 156 return new Builder(clientContext); 157 } 158 159 /** Returns a builder containing all the values of this settings class. */ toBuilder()160 public Builder toBuilder() { 161 return new Builder(this); 162 } 163 GlobalOperationsSettings(Builder settingsBuilder)164 protected GlobalOperationsSettings(Builder settingsBuilder) throws IOException { 165 super(settingsBuilder); 166 } 167 168 /** Builder for GlobalOperationsSettings. */ 169 public static class Builder extends ClientSettings.Builder<GlobalOperationsSettings, Builder> { 170 Builder()171 protected Builder() throws IOException { 172 this(((ClientContext) null)); 173 } 174 Builder(ClientContext clientContext)175 protected Builder(ClientContext clientContext) { 176 super(GlobalOperationsStubSettings.newBuilder(clientContext)); 177 } 178 Builder(GlobalOperationsSettings settings)179 protected Builder(GlobalOperationsSettings settings) { 180 super(settings.getStubSettings().toBuilder()); 181 } 182 Builder(GlobalOperationsStubSettings.Builder stubSettings)183 protected Builder(GlobalOperationsStubSettings.Builder stubSettings) { 184 super(stubSettings); 185 } 186 createDefault()187 private static Builder createDefault() { 188 return new Builder(GlobalOperationsStubSettings.newBuilder()); 189 } 190 getStubSettingsBuilder()191 public GlobalOperationsStubSettings.Builder getStubSettingsBuilder() { 192 return ((GlobalOperationsStubSettings.Builder) getStubSettings()); 193 } 194 195 /** 196 * Applies the given settings updater function to all of the unary API methods in this service. 197 * 198 * <p>Note: This method does not support applying settings to streaming methods. 199 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)200 public Builder applyToAllUnaryMethods( 201 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 202 super.applyToAllUnaryMethods( 203 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 204 return this; 205 } 206 207 /** Returns the builder for the settings used for calls to aggregatedList. */ 208 public PagedCallSettings.Builder< 209 AggregatedListGlobalOperationsRequest, 210 OperationAggregatedList, 211 AggregatedListPagedResponse> aggregatedListSettings()212 aggregatedListSettings() { 213 return getStubSettingsBuilder().aggregatedListSettings(); 214 } 215 216 /** Returns the builder for the settings used for calls to delete. */ 217 public UnaryCallSettings.Builder<DeleteGlobalOperationRequest, DeleteGlobalOperationResponse> deleteSettings()218 deleteSettings() { 219 return getStubSettingsBuilder().deleteSettings(); 220 } 221 222 /** Returns the builder for the settings used for calls to get. */ getSettings()223 public UnaryCallSettings.Builder<GetGlobalOperationRequest, Operation> getSettings() { 224 return getStubSettingsBuilder().getSettings(); 225 } 226 227 /** Returns the builder for the settings used for calls to list. */ 228 public PagedCallSettings.Builder<ListGlobalOperationsRequest, OperationList, ListPagedResponse> listSettings()229 listSettings() { 230 return getStubSettingsBuilder().listSettings(); 231 } 232 233 /** Returns the builder for the settings used for calls to wait. */ waitSettings()234 public UnaryCallSettings.Builder<WaitGlobalOperationRequest, Operation> waitSettings() { 235 return getStubSettingsBuilder().waitSettings(); 236 } 237 238 @Override build()239 public GlobalOperationsSettings build() throws IOException { 240 return new GlobalOperationsSettings(this); 241 } 242 } 243 } 244