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