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