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.iot.v1; 18 19 import static com.google.cloud.iot.v1.DeviceManagerClient.ListDeviceRegistriesPagedResponse; 20 import static com.google.cloud.iot.v1.DeviceManagerClient.ListDevicesPagedResponse; 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.httpjson.InstantiatingHttpJsonChannelProvider; 28 import com.google.api.gax.rpc.ApiClientHeaderProvider; 29 import com.google.api.gax.rpc.ClientContext; 30 import com.google.api.gax.rpc.ClientSettings; 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.iot.v1.stub.DeviceManagerStubSettings; 35 import com.google.iam.v1.GetIamPolicyRequest; 36 import com.google.iam.v1.Policy; 37 import com.google.iam.v1.SetIamPolicyRequest; 38 import com.google.iam.v1.TestIamPermissionsRequest; 39 import com.google.iam.v1.TestIamPermissionsResponse; 40 import com.google.protobuf.Empty; 41 import java.io.IOException; 42 import java.util.List; 43 import javax.annotation.Generated; 44 45 // AUTO-GENERATED DOCUMENTATION AND CLASS. 46 /** 47 * Settings class to configure an instance of {@link DeviceManagerClient}. 48 * 49 * <p>The default instance has everything set to sensible defaults: 50 * 51 * <ul> 52 * <li>The default service address (cloudiot.googleapis.com) and default port (443) are used. 53 * <li>Credentials are acquired automatically through Application Default Credentials. 54 * <li>Retries are configured for idempotent methods but not for non-idempotent methods. 55 * </ul> 56 * 57 * <p>The builder of this class is recursive, so contained classes are themselves builders. When 58 * build() is called, the tree of builders is called to create the complete settings object. 59 * 60 * <p>For example, to set the total timeout of createDeviceRegistry to 30 seconds: 61 * 62 * <pre>{@code 63 * // This snippet has been automatically generated and should be regarded as a code template only. 64 * // It will require modifications to work: 65 * // - It may require correct/in-range values for request initialization. 66 * // - It may require specifying regional endpoints when creating the service client as shown in 67 * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library 68 * DeviceManagerSettings.Builder deviceManagerSettingsBuilder = DeviceManagerSettings.newBuilder(); 69 * deviceManagerSettingsBuilder 70 * .createDeviceRegistrySettings() 71 * .setRetrySettings( 72 * deviceManagerSettingsBuilder 73 * .createDeviceRegistrySettings() 74 * .getRetrySettings() 75 * .toBuilder() 76 * .setTotalTimeout(Duration.ofSeconds(30)) 77 * .build()); 78 * DeviceManagerSettings deviceManagerSettings = deviceManagerSettingsBuilder.build(); 79 * }</pre> 80 */ 81 @Generated("by gapic-generator-java") 82 public class DeviceManagerSettings extends ClientSettings<DeviceManagerSettings> { 83 84 /** Returns the object with the settings used for calls to createDeviceRegistry. */ 85 public UnaryCallSettings<CreateDeviceRegistryRequest, DeviceRegistry> createDeviceRegistrySettings()86 createDeviceRegistrySettings() { 87 return ((DeviceManagerStubSettings) getStubSettings()).createDeviceRegistrySettings(); 88 } 89 90 /** Returns the object with the settings used for calls to getDeviceRegistry. */ getDeviceRegistrySettings()91 public UnaryCallSettings<GetDeviceRegistryRequest, DeviceRegistry> getDeviceRegistrySettings() { 92 return ((DeviceManagerStubSettings) getStubSettings()).getDeviceRegistrySettings(); 93 } 94 95 /** Returns the object with the settings used for calls to updateDeviceRegistry. */ 96 public UnaryCallSettings<UpdateDeviceRegistryRequest, DeviceRegistry> updateDeviceRegistrySettings()97 updateDeviceRegistrySettings() { 98 return ((DeviceManagerStubSettings) getStubSettings()).updateDeviceRegistrySettings(); 99 } 100 101 /** Returns the object with the settings used for calls to deleteDeviceRegistry. */ deleteDeviceRegistrySettings()102 public UnaryCallSettings<DeleteDeviceRegistryRequest, Empty> deleteDeviceRegistrySettings() { 103 return ((DeviceManagerStubSettings) getStubSettings()).deleteDeviceRegistrySettings(); 104 } 105 106 /** Returns the object with the settings used for calls to listDeviceRegistries. */ 107 public PagedCallSettings< 108 ListDeviceRegistriesRequest, 109 ListDeviceRegistriesResponse, 110 ListDeviceRegistriesPagedResponse> listDeviceRegistriesSettings()111 listDeviceRegistriesSettings() { 112 return ((DeviceManagerStubSettings) getStubSettings()).listDeviceRegistriesSettings(); 113 } 114 115 /** Returns the object with the settings used for calls to createDevice. */ createDeviceSettings()116 public UnaryCallSettings<CreateDeviceRequest, Device> createDeviceSettings() { 117 return ((DeviceManagerStubSettings) getStubSettings()).createDeviceSettings(); 118 } 119 120 /** Returns the object with the settings used for calls to getDevice. */ getDeviceSettings()121 public UnaryCallSettings<GetDeviceRequest, Device> getDeviceSettings() { 122 return ((DeviceManagerStubSettings) getStubSettings()).getDeviceSettings(); 123 } 124 125 /** Returns the object with the settings used for calls to updateDevice. */ updateDeviceSettings()126 public UnaryCallSettings<UpdateDeviceRequest, Device> updateDeviceSettings() { 127 return ((DeviceManagerStubSettings) getStubSettings()).updateDeviceSettings(); 128 } 129 130 /** Returns the object with the settings used for calls to deleteDevice. */ deleteDeviceSettings()131 public UnaryCallSettings<DeleteDeviceRequest, Empty> deleteDeviceSettings() { 132 return ((DeviceManagerStubSettings) getStubSettings()).deleteDeviceSettings(); 133 } 134 135 /** Returns the object with the settings used for calls to listDevices. */ 136 public PagedCallSettings<ListDevicesRequest, ListDevicesResponse, ListDevicesPagedResponse> listDevicesSettings()137 listDevicesSettings() { 138 return ((DeviceManagerStubSettings) getStubSettings()).listDevicesSettings(); 139 } 140 141 /** Returns the object with the settings used for calls to modifyCloudToDeviceConfig. */ 142 public UnaryCallSettings<ModifyCloudToDeviceConfigRequest, DeviceConfig> modifyCloudToDeviceConfigSettings()143 modifyCloudToDeviceConfigSettings() { 144 return ((DeviceManagerStubSettings) getStubSettings()).modifyCloudToDeviceConfigSettings(); 145 } 146 147 /** Returns the object with the settings used for calls to listDeviceConfigVersions. */ 148 public UnaryCallSettings<ListDeviceConfigVersionsRequest, ListDeviceConfigVersionsResponse> listDeviceConfigVersionsSettings()149 listDeviceConfigVersionsSettings() { 150 return ((DeviceManagerStubSettings) getStubSettings()).listDeviceConfigVersionsSettings(); 151 } 152 153 /** Returns the object with the settings used for calls to listDeviceStates. */ 154 public UnaryCallSettings<ListDeviceStatesRequest, ListDeviceStatesResponse> listDeviceStatesSettings()155 listDeviceStatesSettings() { 156 return ((DeviceManagerStubSettings) getStubSettings()).listDeviceStatesSettings(); 157 } 158 159 /** Returns the object with the settings used for calls to setIamPolicy. */ setIamPolicySettings()160 public UnaryCallSettings<SetIamPolicyRequest, Policy> setIamPolicySettings() { 161 return ((DeviceManagerStubSettings) getStubSettings()).setIamPolicySettings(); 162 } 163 164 /** Returns the object with the settings used for calls to getIamPolicy. */ getIamPolicySettings()165 public UnaryCallSettings<GetIamPolicyRequest, Policy> getIamPolicySettings() { 166 return ((DeviceManagerStubSettings) getStubSettings()).getIamPolicySettings(); 167 } 168 169 /** Returns the object with the settings used for calls to testIamPermissions. */ 170 public UnaryCallSettings<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()171 testIamPermissionsSettings() { 172 return ((DeviceManagerStubSettings) getStubSettings()).testIamPermissionsSettings(); 173 } 174 175 /** Returns the object with the settings used for calls to sendCommandToDevice. */ 176 public UnaryCallSettings<SendCommandToDeviceRequest, SendCommandToDeviceResponse> sendCommandToDeviceSettings()177 sendCommandToDeviceSettings() { 178 return ((DeviceManagerStubSettings) getStubSettings()).sendCommandToDeviceSettings(); 179 } 180 181 /** Returns the object with the settings used for calls to bindDeviceToGateway. */ 182 public UnaryCallSettings<BindDeviceToGatewayRequest, BindDeviceToGatewayResponse> bindDeviceToGatewaySettings()183 bindDeviceToGatewaySettings() { 184 return ((DeviceManagerStubSettings) getStubSettings()).bindDeviceToGatewaySettings(); 185 } 186 187 /** Returns the object with the settings used for calls to unbindDeviceFromGateway. */ 188 public UnaryCallSettings<UnbindDeviceFromGatewayRequest, UnbindDeviceFromGatewayResponse> unbindDeviceFromGatewaySettings()189 unbindDeviceFromGatewaySettings() { 190 return ((DeviceManagerStubSettings) getStubSettings()).unbindDeviceFromGatewaySettings(); 191 } 192 create(DeviceManagerStubSettings stub)193 public static final DeviceManagerSettings create(DeviceManagerStubSettings stub) 194 throws IOException { 195 return new DeviceManagerSettings.Builder(stub.toBuilder()).build(); 196 } 197 198 /** Returns a builder for the default ExecutorProvider for this service. */ defaultExecutorProviderBuilder()199 public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { 200 return DeviceManagerStubSettings.defaultExecutorProviderBuilder(); 201 } 202 203 /** Returns the default service endpoint. */ getDefaultEndpoint()204 public static String getDefaultEndpoint() { 205 return DeviceManagerStubSettings.getDefaultEndpoint(); 206 } 207 208 /** Returns the default service scopes. */ getDefaultServiceScopes()209 public static List<String> getDefaultServiceScopes() { 210 return DeviceManagerStubSettings.getDefaultServiceScopes(); 211 } 212 213 /** Returns a builder for the default credentials for this service. */ defaultCredentialsProviderBuilder()214 public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { 215 return DeviceManagerStubSettings.defaultCredentialsProviderBuilder(); 216 } 217 218 /** Returns a builder for the default gRPC ChannelProvider for this service. */ defaultGrpcTransportProviderBuilder()219 public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { 220 return DeviceManagerStubSettings.defaultGrpcTransportProviderBuilder(); 221 } 222 223 /** Returns a builder for the default REST ChannelProvider for this service. */ 224 @BetaApi 225 public static InstantiatingHttpJsonChannelProvider.Builder defaultHttpJsonTransportProviderBuilder()226 defaultHttpJsonTransportProviderBuilder() { 227 return DeviceManagerStubSettings.defaultHttpJsonTransportProviderBuilder(); 228 } 229 defaultTransportChannelProvider()230 public static TransportChannelProvider defaultTransportChannelProvider() { 231 return DeviceManagerStubSettings.defaultTransportChannelProvider(); 232 } 233 234 @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") defaultApiClientHeaderProviderBuilder()235 public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { 236 return DeviceManagerStubSettings.defaultApiClientHeaderProviderBuilder(); 237 } 238 239 /** Returns a new gRPC builder for this class. */ newBuilder()240 public static Builder newBuilder() { 241 return Builder.createDefault(); 242 } 243 244 /** Returns a new REST builder for this class. */ 245 @BetaApi newHttpJsonBuilder()246 public static Builder newHttpJsonBuilder() { 247 return Builder.createHttpJsonDefault(); 248 } 249 250 /** Returns a new builder for this class. */ newBuilder(ClientContext clientContext)251 public static Builder newBuilder(ClientContext clientContext) { 252 return new Builder(clientContext); 253 } 254 255 /** Returns a builder containing all the values of this settings class. */ toBuilder()256 public Builder toBuilder() { 257 return new Builder(this); 258 } 259 DeviceManagerSettings(Builder settingsBuilder)260 protected DeviceManagerSettings(Builder settingsBuilder) throws IOException { 261 super(settingsBuilder); 262 } 263 264 /** Builder for DeviceManagerSettings. */ 265 public static class Builder extends ClientSettings.Builder<DeviceManagerSettings, Builder> { 266 Builder()267 protected Builder() throws IOException { 268 this(((ClientContext) null)); 269 } 270 Builder(ClientContext clientContext)271 protected Builder(ClientContext clientContext) { 272 super(DeviceManagerStubSettings.newBuilder(clientContext)); 273 } 274 Builder(DeviceManagerSettings settings)275 protected Builder(DeviceManagerSettings settings) { 276 super(settings.getStubSettings().toBuilder()); 277 } 278 Builder(DeviceManagerStubSettings.Builder stubSettings)279 protected Builder(DeviceManagerStubSettings.Builder stubSettings) { 280 super(stubSettings); 281 } 282 createDefault()283 private static Builder createDefault() { 284 return new Builder(DeviceManagerStubSettings.newBuilder()); 285 } 286 287 @BetaApi createHttpJsonDefault()288 private static Builder createHttpJsonDefault() { 289 return new Builder(DeviceManagerStubSettings.newHttpJsonBuilder()); 290 } 291 getStubSettingsBuilder()292 public DeviceManagerStubSettings.Builder getStubSettingsBuilder() { 293 return ((DeviceManagerStubSettings.Builder) getStubSettings()); 294 } 295 296 /** 297 * Applies the given settings updater function to all of the unary API methods in this service. 298 * 299 * <p>Note: This method does not support applying settings to streaming methods. 300 */ applyToAllUnaryMethods( ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater)301 public Builder applyToAllUnaryMethods( 302 ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) { 303 super.applyToAllUnaryMethods( 304 getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); 305 return this; 306 } 307 308 /** Returns the builder for the settings used for calls to createDeviceRegistry. */ 309 public UnaryCallSettings.Builder<CreateDeviceRegistryRequest, DeviceRegistry> createDeviceRegistrySettings()310 createDeviceRegistrySettings() { 311 return getStubSettingsBuilder().createDeviceRegistrySettings(); 312 } 313 314 /** Returns the builder for the settings used for calls to getDeviceRegistry. */ 315 public UnaryCallSettings.Builder<GetDeviceRegistryRequest, DeviceRegistry> getDeviceRegistrySettings()316 getDeviceRegistrySettings() { 317 return getStubSettingsBuilder().getDeviceRegistrySettings(); 318 } 319 320 /** Returns the builder for the settings used for calls to updateDeviceRegistry. */ 321 public UnaryCallSettings.Builder<UpdateDeviceRegistryRequest, DeviceRegistry> updateDeviceRegistrySettings()322 updateDeviceRegistrySettings() { 323 return getStubSettingsBuilder().updateDeviceRegistrySettings(); 324 } 325 326 /** Returns the builder for the settings used for calls to deleteDeviceRegistry. */ 327 public UnaryCallSettings.Builder<DeleteDeviceRegistryRequest, Empty> deleteDeviceRegistrySettings()328 deleteDeviceRegistrySettings() { 329 return getStubSettingsBuilder().deleteDeviceRegistrySettings(); 330 } 331 332 /** Returns the builder for the settings used for calls to listDeviceRegistries. */ 333 public PagedCallSettings.Builder< 334 ListDeviceRegistriesRequest, 335 ListDeviceRegistriesResponse, 336 ListDeviceRegistriesPagedResponse> listDeviceRegistriesSettings()337 listDeviceRegistriesSettings() { 338 return getStubSettingsBuilder().listDeviceRegistriesSettings(); 339 } 340 341 /** Returns the builder for the settings used for calls to createDevice. */ createDeviceSettings()342 public UnaryCallSettings.Builder<CreateDeviceRequest, Device> createDeviceSettings() { 343 return getStubSettingsBuilder().createDeviceSettings(); 344 } 345 346 /** Returns the builder for the settings used for calls to getDevice. */ getDeviceSettings()347 public UnaryCallSettings.Builder<GetDeviceRequest, Device> getDeviceSettings() { 348 return getStubSettingsBuilder().getDeviceSettings(); 349 } 350 351 /** Returns the builder for the settings used for calls to updateDevice. */ updateDeviceSettings()352 public UnaryCallSettings.Builder<UpdateDeviceRequest, Device> updateDeviceSettings() { 353 return getStubSettingsBuilder().updateDeviceSettings(); 354 } 355 356 /** Returns the builder for the settings used for calls to deleteDevice. */ deleteDeviceSettings()357 public UnaryCallSettings.Builder<DeleteDeviceRequest, Empty> deleteDeviceSettings() { 358 return getStubSettingsBuilder().deleteDeviceSettings(); 359 } 360 361 /** Returns the builder for the settings used for calls to listDevices. */ 362 public PagedCallSettings.Builder< 363 ListDevicesRequest, ListDevicesResponse, ListDevicesPagedResponse> listDevicesSettings()364 listDevicesSettings() { 365 return getStubSettingsBuilder().listDevicesSettings(); 366 } 367 368 /** Returns the builder for the settings used for calls to modifyCloudToDeviceConfig. */ 369 public UnaryCallSettings.Builder<ModifyCloudToDeviceConfigRequest, DeviceConfig> modifyCloudToDeviceConfigSettings()370 modifyCloudToDeviceConfigSettings() { 371 return getStubSettingsBuilder().modifyCloudToDeviceConfigSettings(); 372 } 373 374 /** Returns the builder for the settings used for calls to listDeviceConfigVersions. */ 375 public UnaryCallSettings.Builder< 376 ListDeviceConfigVersionsRequest, ListDeviceConfigVersionsResponse> listDeviceConfigVersionsSettings()377 listDeviceConfigVersionsSettings() { 378 return getStubSettingsBuilder().listDeviceConfigVersionsSettings(); 379 } 380 381 /** Returns the builder for the settings used for calls to listDeviceStates. */ 382 public UnaryCallSettings.Builder<ListDeviceStatesRequest, ListDeviceStatesResponse> listDeviceStatesSettings()383 listDeviceStatesSettings() { 384 return getStubSettingsBuilder().listDeviceStatesSettings(); 385 } 386 387 /** Returns the builder for the settings used for calls to setIamPolicy. */ setIamPolicySettings()388 public UnaryCallSettings.Builder<SetIamPolicyRequest, Policy> setIamPolicySettings() { 389 return getStubSettingsBuilder().setIamPolicySettings(); 390 } 391 392 /** Returns the builder for the settings used for calls to getIamPolicy. */ getIamPolicySettings()393 public UnaryCallSettings.Builder<GetIamPolicyRequest, Policy> getIamPolicySettings() { 394 return getStubSettingsBuilder().getIamPolicySettings(); 395 } 396 397 /** Returns the builder for the settings used for calls to testIamPermissions. */ 398 public UnaryCallSettings.Builder<TestIamPermissionsRequest, TestIamPermissionsResponse> testIamPermissionsSettings()399 testIamPermissionsSettings() { 400 return getStubSettingsBuilder().testIamPermissionsSettings(); 401 } 402 403 /** Returns the builder for the settings used for calls to sendCommandToDevice. */ 404 public UnaryCallSettings.Builder<SendCommandToDeviceRequest, SendCommandToDeviceResponse> sendCommandToDeviceSettings()405 sendCommandToDeviceSettings() { 406 return getStubSettingsBuilder().sendCommandToDeviceSettings(); 407 } 408 409 /** Returns the builder for the settings used for calls to bindDeviceToGateway. */ 410 public UnaryCallSettings.Builder<BindDeviceToGatewayRequest, BindDeviceToGatewayResponse> bindDeviceToGatewaySettings()411 bindDeviceToGatewaySettings() { 412 return getStubSettingsBuilder().bindDeviceToGatewaySettings(); 413 } 414 415 /** Returns the builder for the settings used for calls to unbindDeviceFromGateway. */ 416 public UnaryCallSettings.Builder< 417 UnbindDeviceFromGatewayRequest, UnbindDeviceFromGatewayResponse> unbindDeviceFromGatewaySettings()418 unbindDeviceFromGatewaySettings() { 419 return getStubSettingsBuilder().unbindDeviceFromGatewaySettings(); 420 } 421 422 @Override build()423 public DeviceManagerSettings build() throws IOException { 424 return new DeviceManagerSettings(this); 425 } 426 } 427 } 428