diff --git a/spring-cloud-generator/pom.xml b/spring-cloud-generator/pom.xml index b53a5cb598..48e8880eef 100644 --- a/spring-cloud-generator/pom.xml +++ b/spring-cloud-generator/pom.xml @@ -58,6 +58,12 @@ 4.12 test + + com.google.truth + truth + 1.1.3 + test + diff --git a/spring-cloud-generator/scripts/generate-library-list.sh b/spring-cloud-generator/scripts/generate-library-list.sh index e6bbde6505..627b30a78c 100755 --- a/spring-cloud-generator/scripts/generate-library-list.sh +++ b/spring-cloud-generator/scripts/generate-library-list.sh @@ -33,7 +33,6 @@ for d in ./google-cloud-java/*java-*/; do api_shortname=$(cat $d/.repo-metadata.json | jq -r .api_shortname) distribution_name=$(cat $d/.repo-metadata.json | jq -r .distribution_name) library_type=$(cat $d/.repo-metadata.json | jq -r .library_type) - transport=$(cat $d/.repo-metadata.json | jq -r .transport) release_level=$(cat $d/.repo-metadata.json | jq -r .release_level) monorepo_folder=$(basename $d) @@ -44,10 +43,6 @@ for d in ./google-cloud-java/*java-*/; do echo "$d: non auto type: $library_type" continue fi - if [[ $transport != *grpc* ]] ; then - echo "$d: transport type not in scope: $transport" - continue - fi if [[ $group_id != "com.google.cloud" ]] ; then echo "$d: group_id not in scope: $group_id" continue diff --git a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringAutoConfigClassComposer.java b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringAutoConfigClassComposer.java index f2fdc93e57..649c10d5eb 100644 --- a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringAutoConfigClassComposer.java +++ b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringAutoConfigClassComposer.java @@ -109,12 +109,9 @@ public GapicClass generate(GapicContext context, Service service) { GapicClass.Kind kind = Kind.MAIN; GapicServiceConfig gapicServiceConfig = context.serviceConfig(); + Transport transport = context.transport(); Expr thisExpr = ValueExpr.withValue(ThisObjectValue.withType(dynamicTypes.get(className))); - Transport transport = context.transport(); - boolean hasRestOption = - (transport.equals(Transport.GRPC_REST) || transport.equals(Transport.REST)) - && service.hasAnyEnabledMethodsForTransport(Transport.REST); String serviceSettingsMethodName = JavaStyle.toLowerCamelCase(service.name()) + "Settings"; ClassDefinition classDef = @@ -132,16 +129,16 @@ public GapicClass generate(GapicContext context, Service service) { createConstructor(service, className, dynamicTypes, thisExpr), createTransportChannelProviderBeanMethod( service, + transport, transportChannelProviderName, dynamicTypes, - thisExpr, - hasRestOption), + thisExpr), createSettingsBeanMethod( service, + transport, transportChannelProviderName, dynamicTypes, thisExpr, - hasRestOption, serviceSettingsMethodName), createClientBeanMethod(dynamicTypes, service, serviceSettingsMethodName), createUserAgentHeaderProviderMethod( @@ -157,7 +154,7 @@ private static List createMemberVariables( Map types, GapicServiceConfig serviceConfig) { - // private final LanguageProperties clientProperties; + // Create clientProperties variable ExprStatement clientPropertiesStatement = ComposerUtils.createMemberVarStatement( "clientProperties", @@ -190,7 +187,7 @@ private static MethodDefinition createConstructor( .setType(STATIC_TYPES.get("CredentialsProvider")) .build()); - // this.clientProperties = clientProperties; + // Assign this.clientProperties AssignmentExpr thisClientPropertiesAssignmentExpr = AssignmentExpr.builder() .setVariableExpr( @@ -200,11 +197,8 @@ private static MethodDefinition createConstructor( ExprStatement thisClientPropertiesAssignmentStatement = ExprStatement.withExpr(thisClientPropertiesAssignmentExpr); - // if (this.clientProperties.getCredentials().hasKey()) { - // this.credentialsProvider = new DefaultCredentialsProvider(this.clientProperties); - // } else { - // this.credentialsProvider = credentialsProvider; - // } + // If credentials configured through properties, create DefaultCredentialsProvider from properties + // Otherwise use credentialsProvider through constructor injection VariableExpr thisClientProperties = clientPropertiesVarExpr.toBuilder().setExprReferenceExpr(thisExpr).build(); AssignmentExpr.Builder thisCredentialsProviderAssignmentExprBuilder = @@ -274,13 +268,7 @@ private static MethodDefinition createConstructor( private static List createClassAnnotations( Service service, Map types) { - // @AutoConfiguration - // @AutoConfigureAfter(GcpContextAutoConfiguration.class) - // @ConditionalOnClass(LanguageServiceClient.class) - // @ConditionalOnProperty(value = - // "com.google.cloud.language.v1.spring.auto.language-service.enabled", matchIfMissing = true) - // @EnableConfigurationProperties(LanguageProperties.class) - + // Generates: @ConditionalOnProperty(value = .enabled", matchIfMissing = true) AssignmentExpr valueStringAssignmentExpr = AssignmentExpr.builder() .setVariableExpr( @@ -308,6 +296,7 @@ private static List createClassAnnotations( .addDescription(matchIfMissingAssignmentExpr) .build(); + // Generates: @ConditionalOnClass(Client.class) AnnotationNode conditionalOnClassNode = AnnotationNode.builder() .setType(STATIC_TYPES.get("ConditionalOnClass")) @@ -318,6 +307,8 @@ private static List createClassAnnotations( .setStaticReferenceType(types.get("ServiceClient")) .build()) .build(); + + // Generates: @AutoConfigureAfter(GcpContextAutoConfiguration.class) AnnotationNode autoConfigureAfterNode = AnnotationNode.builder() .setType(STATIC_TYPES.get("AutoConfigureAfter")) @@ -328,8 +319,12 @@ private static List createClassAnnotations( .setStaticReferenceType(STATIC_TYPES.get("GcpContextAutoConfiguration")) .build()) .build(); + + // Generates: @AutoConfiguration AnnotationNode configurationNode = AnnotationNode.builder().setType(STATIC_TYPES.get("AutoConfiguration")).build(); + + // Generates: @EnableConfigurationProperties(SpringProperties.class) AnnotationNode enableConfigurationPropertiesNode = AnnotationNode.builder() .setType(STATIC_TYPES.get("EnableConfigurationProperties")) @@ -351,10 +346,10 @@ private static List createClassAnnotations( private static MethodDefinition createTransportChannelProviderBeanMethod( Service service, + Transport transport, String methodName, Map types, - Expr thisExpr, - boolean hasRestOption) { + Expr thisExpr) { AssignmentExpr nameStringAssignmentExpr = AssignmentExpr.builder() .setVariableExpr( @@ -379,7 +374,8 @@ private static MethodDefinition createTransportChannelProviderBeanMethod( Arrays.asList( AnnotationNode.withType(STATIC_TYPES.get("Bean")), conditionalOnMissingBean)); - // LanguageServiceSettings.defaultTransportChannelProvider() + // For GRPC-only or REST-only libraries, generates code to use default provider: + // Settings.defaultTransportChannelProvider() MethodInvocationExpr defaultTransportChannelProviderExpr = MethodInvocationExpr.builder() .setMethodName("defaultTransportChannelProvider") @@ -387,10 +383,8 @@ private static MethodDefinition createTransportChannelProviderBeanMethod( .setReturnType(STATIC_TYPES.get("TransportChannelProvider")) .build(); - if (hasRestOption) { - // if (this.clientProperties.isUseRest()) { - // return LanguageServiceSettings.defaultHttpJsonTransportProviderBuilder().build(); - // } + // For GRPC+REST libraries, generates code to choose provider according to configuration property + if (ComposerUtils.shouldSupportRestOptionWithGrpcDefault(transport, service)) { Variable clientPropertiesVar = Variable.builder() .setName("clientProperties") @@ -409,7 +403,8 @@ private static MethodDefinition createTransportChannelProviderBeanMethod( .setExprReferenceExpr(thisClientPropertiesVarExpr) .build(); - // LanguageServiceSettings.defaultHttpJsonTransportProviderBuilder().build() + // If useRest property is true, generates code to use HTTP/JSON transport provider: + // Settings.defaultHttpJsonTransportProviderBuilder().build() Expr defaultTransportProviderExprChain = MethodInvocationExpr.builder() .setStaticReferenceType(types.get("ServiceSettings")) @@ -451,12 +446,13 @@ private static IfStatement createIfStatement( private static MethodDefinition createSettingsBeanMethod( Service service, + Transport transport, String transportChannelProviderName, Map types, Expr thisExpr, - boolean hasRestOption, String serviceSettingsMethodName) { - // argument variables: + + // Generates code for argument variables: VariableExpr credentialsProviderVariableExpr = VariableExpr.withVariable( Variable.builder() @@ -499,14 +495,8 @@ private static MethodDefinition createSettingsBeanMethod( .setExprReferenceExpr(thisExpr) .build(); - if (hasRestOption) { - // For GRPC+REST libraries - // LanguageServiceSettings.Builder clientSettingsBuilder; - // if (this.clientProperties.isUseRest()) { - // clientSettingsBuilder = LanguageServiceSettings.newHttpJsonBuilder(); - // } else { - // clientSettingsBuilder = LanguageServiceSettings.newBuilder(); - // } + if (ComposerUtils.shouldSupportRestOptionWithGrpcDefault(transport, service)) { + // For GRPC+REST libraries, generates code to choose builder according to configuration property MethodInvocationExpr getUseRest = MethodInvocationExpr.builder() .setMethodName("getUseRest") @@ -514,7 +504,8 @@ private static MethodDefinition createSettingsBeanMethod( .setExprReferenceExpr(thisClientPropertiesVarExpr) .build(); - // clientSettingsBuilder = LanguageServiceSettings.newHttpJsonBuilder(); + // If useRest property is true, generates code to use HTTP/JSON builder: + // Settings.newHttpJsonBuilder() Expr newHttpJsonBuilderExpr = MethodInvocationExpr.builder() .setStaticReferenceType(types.get("ServiceSettings")) @@ -528,7 +519,6 @@ private static MethodDefinition createSettingsBeanMethod( .setValueExpr(newHttpJsonBuilderExpr) .build(); - // clientSettingsBuilder = LanguageServiceSettings.newBuilder(); AssignmentExpr newBuilderAssignmentExpr = AssignmentExpr.builder() .setVariableExpr(VariableExpr.withVariable(settingBuilderVariable)) @@ -554,10 +544,8 @@ private static MethodDefinition createSettingsBeanMethod( bodyStatements.add(setClientSettingsBuilderStatement); } else { - // For GRPC-only libraries - // LanguageServiceSettings.Builder clientSettingsBuilder = - // LanguageServiceSettings.newBuilder(); - + // For GRPC-only or REST-only libraries, generates code to use default builder: + // Settings.newBuilder() AssignmentExpr clientSettingsBuilderAssignmentExpr = AssignmentExpr.builder() .setVariableExpr(settingsVarExpr) @@ -583,15 +571,12 @@ private static MethodDefinition createSettingsBeanMethod( .setMethodName("setCredentialsProvider") .setArguments(thisCredentialsProvider) .build(); - // clientSettingsBuilder - // .setTransportChannelProvider(defaultTransportChannelProvider) settingsBuilderExpr = MethodInvocationExpr.builder() .setExprReferenceExpr(settingsBuilderExpr) .setMethodName("setTransportChannelProvider") .setArguments(transportChannelProviderVariableExpr) .build(); - // .setHeaderProvider(this.serAgentHeaderProvider()); MethodInvocationExpr userAgentHeaderProviderInvocation = MethodInvocationExpr.builder() .setExprReferenceExpr(thisExpr) @@ -608,12 +593,7 @@ private static MethodDefinition createSettingsBeanMethod( bodyStatements.add(ExprStatement.withExpr(settingsBuilderExpr)); - // if (this.clientProperties.getQuotaProjectId() != null) { - // clientSettingsBuilder.setQuotaProjectId(clientProperties.getQuotaProjectId()); - // LOGGER.info("Quota project id set to: " + clientProperties.getQuotaProjectId() - // + ", this overrides project id from credentials."); - // } - + // Set quota project ID if specified via configuration property MethodInvocationExpr getQuotaProjectId = MethodInvocationExpr.builder() .setMethodName("getQuotaProjectId") @@ -623,7 +603,6 @@ private static MethodDefinition createSettingsBeanMethod( RelationalOperationExpr projectIdIsNull = RelationalOperationExpr.notEqualToWithExprs(getQuotaProjectId, ValueExpr.createNullExpr()); - // clientSettingsBuilder.setQuotaProjectId(clientProperties.getQuotaProjectId()); MethodInvocationExpr setQuotaProjectId = MethodInvocationExpr.builder() .setExprReferenceExpr(VariableExpr.withVariable(settingBuilderVariable)) @@ -648,14 +627,7 @@ private static MethodDefinition createSettingsBeanMethod( bodyStatements.add(setQuotaProjectIdStatement); - // if (this.clientProperties.getExecutorThreadCount() != null) { - // ExecutorProvider executorProvider = - // LanguageServiceSettings.defaultExecutorProviderBuilder() - // .setExecutorThreadCount(clientProperties.getExecutorThreadCount()).build(); - // clientSettingsBuilder - // .setBackgroundExecutorProvider(executorProvider); - // } - + // Set executor thread count if specified via configuration property MethodInvocationExpr getExecutorThreadCount = MethodInvocationExpr.builder() .setMethodName("getExecutorThreadCount") @@ -721,14 +693,13 @@ private static MethodDefinition createSettingsBeanMethod( bodyStatements.add(setBackgroundExecutorProviderStatement); // If service-level properties configured, update retry settings for each method - Variable serviceRetryPropertiesVar = Variable.builder().setName("serviceRetry").setType(types.get("Retry")).build(); VariableExpr serviceRetryPropertiesVarExpr = VariableExpr.builder().setVariable(serviceRetryPropertiesVar).setIsDecl(true).build(); - // clientProperties.getRetry() + // Service-level retry configuration: clientProperties.getRetry() MethodInvocationExpr serviceRetryPropertiesExpr = MethodInvocationExpr.builder() .setExprReferenceExpr(VariableExpr.withVariable(clientPropertiesVar)) @@ -736,7 +707,6 @@ private static MethodDefinition createSettingsBeanMethod( .setReturnType(types.get("Retry")) .build(); - // Retry retrySettings = clientProperties.getRetrySettings(); AssignmentExpr serviceRetrySettingsExpr = AssignmentExpr.builder() .setVariableExpr(serviceRetryPropertiesVarExpr) @@ -785,7 +755,7 @@ private static MethodDefinition createSettingsBeanMethod( VariableExpr methodRetryPropertiesVarExpr = VariableExpr.builder().setVariable(methodRetryPropertiesVar).setIsDecl(true).build(); - // clientProperties.getRetry() + // Method-level retry configuration: clientProperties.getRetry() MethodInvocationExpr methodRetryPropertiesExpr = MethodInvocationExpr.builder() .setExprReferenceExpr(VariableExpr.withVariable(clientPropertiesVar)) @@ -882,13 +852,13 @@ private static List createUpdateRetrySettingsStatements( .setType(STATIC_TYPES.get("RetrySettings")) .build(); - // clientSettingsBuilder.analyzeSentimentSettings() MethodInvocationExpr methodSettingsExpr = MethodInvocationExpr.builder() .setExprReferenceExpr(VariableExpr.withVariable(settingBuilderVariable)) .setMethodName(settingsVarName) .build(); + // Generates code to get retry settings (client library defaults): // clientSettingsBuilder.analyzeSentimentSettings().getRetrySettings() MethodInvocationExpr getRetrySettingsExpr = MethodInvocationExpr.builder() @@ -906,6 +876,7 @@ private static List createUpdateRetrySettingsStatements( .setReturnType(STATIC_TYPES.get("RetrySettings")) .build(); + // Generates code to set retry settings: // clientSettingsBuilder.analyzeSentimentSettings().setRetrySettings(analyzeSentimentRetrySettings) MethodInvocationExpr setRetrySettingsExpr = MethodInvocationExpr.builder() @@ -966,11 +937,8 @@ private static MethodDefinition createClientBeanMethod( private static MethodDefinition createUserAgentHeaderProviderMethod( String serviceName, String className, Map types, Expr thisExpr) { - // private HeaderProvider userAgentHeaderProvider() { - // String springLibrary = "spring-autogen-language"; - // String version = this.getClass().getPackage().getImplementationVersion(); - // return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); - // } + // Generates method definition that returns a spring-specific HeaderProvider, + // with user-agent header set for metrics List bodyStatements = new ArrayList<>(); VariableExpr springLibStringVariableExpr = diff --git a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringComposer.java b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringComposer.java index 9eaffff62b..9d41f2db56 100644 --- a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringComposer.java +++ b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringComposer.java @@ -24,7 +24,6 @@ import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicContext; import com.google.api.generator.gapic.model.GapicPackageInfo; -import com.google.api.generator.gapic.model.Transport; import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.Arrays; @@ -66,12 +65,8 @@ protected static List generatePerServiceClasses(GapicContext context .services() .forEach( s -> { - // Transport.REST is out of scope for Spring composers. - if (context.transport() == Transport.GRPC - || context.transport() == Transport.GRPC_REST) { - clazzes.add(SpringAutoConfigClassComposer.instance().generate(context, s)); - clazzes.add(SpringPropertiesClassComposer.instance().generate(context, s)); - } + clazzes.add(SpringAutoConfigClassComposer.instance().generate(context, s)); + clazzes.add(SpringPropertiesClassComposer.instance().generate(context, s)); }); return clazzes; } diff --git a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringPropertiesClassComposer.java b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringPropertiesClassComposer.java index c731f80c18..7e52ff9778 100644 --- a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringPropertiesClassComposer.java +++ b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/SpringPropertiesClassComposer.java @@ -41,7 +41,6 @@ import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicClass.Kind; import com.google.api.generator.gapic.model.GapicContext; -import com.google.api.generator.gapic.model.GapicServiceConfig; import com.google.api.generator.gapic.model.Method; import com.google.api.generator.gapic.model.Service; import com.google.api.generator.gapic.model.Transport; @@ -75,15 +74,9 @@ public static SpringPropertiesClassComposer instance() { public GapicClass generate(GapicContext context, Service service) { String packageName = Utils.getSpringPackageName(service.pakkage()); String className = Utils.getServicePropertiesClassName(service); - GapicServiceConfig gapicServiceConfig = context.serviceConfig(); Map dynamicTypes = createDynamicTypes(service, packageName); Transport transport = context.transport(); - boolean hasRestOption = - (transport.equals(Transport.GRPC_REST) || transport.equals(Transport.REST)) - && service.hasAnyEnabledMethodsForTransport(Transport.REST); - // TODO: this is the prefix user will use to set properties, may need to change depending on - // branding. AnnotationNode classAnnotationNode = AnnotationNode.builder() .setType(STATIC_TYPES.get("ConfigurationProperties")) @@ -99,23 +92,19 @@ public GapicClass generate(GapicContext context, Service service) { .setName(className) .setScope(ScopeNode.PUBLIC) .setStatements( - createMemberVariables( - service, packageName, dynamicTypes, gapicServiceConfig, hasRestOption)) + createMemberVariables(service, transport, dynamicTypes)) .setMethods( - createGetterSetters(service, dynamicTypes, gapicServiceConfig, hasRestOption)) + createGetterSetters(service, transport, dynamicTypes)) .setAnnotations(Arrays.asList(classAnnotationNode)) .setImplementsTypes(Arrays.asList(STATIC_TYPES.get("CredentialsSupplier"))) .build(); return GapicClass.create(Kind.MAIN, classDef); - // return null; } private static List createMemberVariables( Service service, - String packageName, - Map types, - GapicServiceConfig serviceConfig, - boolean hasRestOption) { + Transport transport, + Map types) { String serviceName = service.name(); List statements = new ArrayList<>(); @@ -126,9 +115,8 @@ private static List createMemberVariables( List nestedPropertyAnnotations = Arrays.asList(AnnotationNode.withType(STATIC_TYPES.get("NestedConfigurationProperty"))); - // @NestedConfigurationProperty - // private final Credentials credentials = new - // Credentials("https://www.googleapis.com/auth/cloud-language"); + // Generates credentials variable: + // private final Credentials credentials = new Credentials("https://www.googleapis.com/auth/cloud-language"); NewObjectExpr defaultCredentialScopes = builder() .setType(STATIC_TYPES.get("Credentials")) @@ -146,19 +134,21 @@ private static List createMemberVariables( nestedPropertyAnnotations); statements.add(SpringPropertiesCommentComposer.createCredentialsPropertyComment()); statements.add(credentialsStatement); - // private String quotaProjectId; + // Generates quotaProjectId variable ExprStatement quotaProjectIdVarStatement = ComposerUtils.createMemberVarStatement( "quotaProjectId", TypeNode.STRING, false, null, null); statements.add(SpringPropertiesCommentComposer.createQuotaProjectIdPropertyComment()); statements.add(quotaProjectIdVarStatement); - // private Integer executorThreadCount; + // Generates executorThreadCount variable ExprStatement executorThreadCountVarStatement = ComposerUtils.createMemberVarStatement( "executorThreadCount", TypeNode.INT_OBJECT, false, null, null); statements.add(SpringPropertiesCommentComposer.createExecutorThreadCountPropertyComment()); statements.add(executorThreadCountVarStatement); - if (hasRestOption) { + // For GRPC+REST libraries, provide configuration property to override GRPC default and use REST transport instead + // For GRPC-only and REST-only libraries, this property is not provided + if (ComposerUtils.shouldSupportRestOptionWithGrpcDefault(transport, service)) { ExprStatement useRestVarStatement = ComposerUtils.createMemberVarStatement( "useRest", @@ -170,7 +160,7 @@ private static List createMemberVariables( statements.add(SpringPropertiesCommentComposer.createUseRestPropertyComment()); statements.add(useRestVarStatement); } - // private Retry retry; + // Generates retry variable; ExprStatement retryPropertiesStatement = ComposerUtils.createMemberVarStatement( "retry", types.get("Retry"), false, null, nestedPropertyAnnotations); @@ -193,9 +183,8 @@ private static List createMemberVariables( private static List createGetterSetters( Service service, - Map types, - GapicServiceConfig gapicServiceConfig, - boolean hasRestOption) { + Transport transport, + Map types) { TypeNode thisClassType = types.get(Utils.getServicePropertiesClassName(service)); List methodDefinitions = new ArrayList<>(); @@ -209,7 +198,7 @@ private static List createGetterSetters( methodDefinitions.add( createGetterMethod(thisClassType, "quotaProjectId", TypeNode.STRING, null)); methodDefinitions.add(createSetterMethod(thisClassType, "quotaProjectId", TypeNode.STRING)); - if (hasRestOption) { + if (ComposerUtils.shouldSupportRestOptionWithGrpcDefault(transport, service)) { methodDefinitions.add(createGetterMethod(thisClassType, "useRest", TypeNode.BOOLEAN, null)); methodDefinitions.add(createSetterMethod(thisClassType, "useRest", TypeNode.BOOLEAN)); } diff --git a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/comment/SpringAutoconfigCommentComposer.java b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/comment/SpringAutoconfigCommentComposer.java index 2c442ac07a..480c020b3a 100644 --- a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/comment/SpringAutoconfigCommentComposer.java +++ b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/composer/comment/SpringAutoconfigCommentComposer.java @@ -43,8 +43,9 @@ public class SpringAutoconfigCommentComposer { + "configuration data files."; public static final String TRANSPORT_CHANNEL_PROVIDER_GENERAL_DESCRIPTION = - "Provides a default transport channel provider bean. The default is gRPC and will default to it unless the " - + "useRest option is supported and provided to use HTTP transport instead"; + "Provides a default transport channel provider bean, corresponding to the client library's default " + + "transport channel provider. If the library supports both GRPC and REST transport, and " + + "the useRest property is configured, the HTTP/JSON transport provider will be used instead of GRPC."; public static final String TRANSPORT_CHANNEL_PROVIDER_RETURN = "a default transport channel provider."; public static final String CLIENT_SETTINGS_BEAN_GENERAL_DESCRIPTION = diff --git a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/utils/ComposerUtils.java b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/utils/ComposerUtils.java index 135622cbbd..876c677baf 100644 --- a/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/utils/ComposerUtils.java +++ b/spring-cloud-generator/src/main/java/com/google/cloud/generator/spring/utils/ComposerUtils.java @@ -24,11 +24,17 @@ import com.google.api.generator.engine.ast.TypeNode; import com.google.api.generator.engine.ast.Variable; import com.google.api.generator.engine.ast.VariableExpr; +import com.google.api.generator.gapic.model.Service; +import com.google.api.generator.gapic.model.Transport; import java.util.Collections; import java.util.List; public class ComposerUtils { + public static Boolean shouldSupportRestOptionWithGrpcDefault(Transport transport, Service service) { + return transport.equals(Transport.GRPC_REST) && service.hasAnyEnabledMethodsForTransport(Transport.REST); + } + public static ExprStatement createMemberVarStatement( String varName, TypeNode varType, diff --git a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/SpringAutoConfigClassComposerTest.java b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/SpringAutoConfigClassComposerTest.java index 01cf9e8103..da2d68ff62 100644 --- a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/SpringAutoConfigClassComposerTest.java +++ b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/SpringAutoConfigClassComposerTest.java @@ -16,6 +16,8 @@ package com.google.cloud.generator.spring.composer; +import static com.google.common.truth.Truth.assertThat; + import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicContext; import com.google.api.generator.gapic.model.Service; @@ -27,44 +29,64 @@ import org.junit.Test; public class SpringAutoConfigClassComposerTest { - private GapicContext context; + private GapicContext echoContext; + private GapicContext echoGrpcRestContext; + private GapicContext echoRestContext; private GapicContext wickedContext; + private Service echoProtoService; + private Service echoGrpcRestProtoService; + private Service echoRestProtoService; private Service wickedProtoService; @Before public void setUp() { - this.context = TestProtoLoader.instance().parseShowcaseEcho(); - this.echoProtoService = this.context.services().get(0); + this.echoContext = TestProtoLoader.instance().parseShowcaseEcho(); + this.echoProtoService = this.echoContext.services().get(0); + this.echoGrpcRestContext = this.echoContext.toBuilder().setTransport(Transport.GRPC_REST).build(); + this.echoGrpcRestProtoService = this.echoGrpcRestContext.services().get(0); + this.echoRestContext = this.echoContext.toBuilder().setTransport(Transport.REST).build(); + this.echoRestProtoService = this.echoRestContext.services().get(0); this.wickedContext = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); this.wickedProtoService = this.wickedContext.services().get(0); } @Test public void generateAutoConfigClazzGrpcTest() { + assertThat(this.echoContext.transport()).isEqualTo(Transport.GRPC); GapicClass clazz = - SpringAutoConfigClassComposer.instance().generate(this.context, this.echoProtoService); + SpringAutoConfigClassComposer.instance().generate(this.echoContext, this.echoProtoService); String fileName = clazz.classDefinition().classIdentifier() + "Grpc.golden"; Assert.assertGoldenClass(this.getClass(), clazz, fileName); } @Test public void generateAutoConfigClazzGrpcRestTest() { - GapicContext contextGrpcRest = - this.context.toBuilder().setTransport(Transport.GRPC_REST).build(); + assertThat(this.echoGrpcRestContext.transport()).isEqualTo(Transport.GRPC_REST); GapicClass clazz = - SpringAutoConfigClassComposer.instance().generate(contextGrpcRest, this.echoProtoService); + SpringAutoConfigClassComposer.instance() + .generate(this.echoGrpcRestContext, this.echoGrpcRestProtoService); String fileName = clazz.classDefinition().classIdentifier() + "GrpcRest.golden"; Assert.assertGoldenClass(this.getClass(), clazz, fileName); } @Test public void generateAutoConfigClazzNoRestRpcsTest() { - GapicContext contextGrpcRest = - this.wickedContext.toBuilder().setTransport(Transport.GRPC_REST).build(); + assertThat(this.wickedContext.transport()).isEqualTo(Transport.GRPC_REST); GapicClass clazz = - SpringAutoConfigClassComposer.instance().generate(contextGrpcRest, this.wickedProtoService); + SpringAutoConfigClassComposer.instance() + .generate(this.wickedContext, this.wickedProtoService); String fileName = clazz.classDefinition().classIdentifier() + "NoRestRpcs.golden"; Assert.assertGoldenClass(this.getClass(), clazz, fileName); } + + @Test + public void generateAutoConfigClazzRestTest() { + assertThat(this.echoRestContext.transport()).isEqualTo(Transport.REST); + GapicClass clazz = + SpringAutoConfigClassComposer.instance() + .generate(this.echoRestContext, this.echoRestProtoService); + String fileName = clazz.classDefinition().classIdentifier() + "Rest.golden"; + Assert.assertGoldenClass(this.getClass(), clazz, fileName); + } } diff --git a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/SpringPropertiesClassComposerTest.java b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/SpringPropertiesClassComposerTest.java index 47ca13a40d..0dea711e8f 100644 --- a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/SpringPropertiesClassComposerTest.java +++ b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/SpringPropertiesClassComposerTest.java @@ -16,6 +16,8 @@ package com.google.cloud.generator.spring.composer; +import static com.google.common.truth.Truth.assertThat; + import com.google.api.generator.gapic.model.GapicClass; import com.google.api.generator.gapic.model.GapicContext; import com.google.api.generator.gapic.model.Service; @@ -27,44 +29,63 @@ import org.junit.Test; public class SpringPropertiesClassComposerTest { - private GapicContext context; + private GapicContext echoContext; + private GapicContext echoGrpcRestContext; + private GapicContext echoRestContext; private GapicContext wickedContext; private Service echoProtoService; + private Service echoGrpcRestProtoService; + private Service echoRestProtoService; private Service wickedProtoService; @Before public void setUp() { - this.context = TestProtoLoader.instance().parseShowcaseEcho(); - this.echoProtoService = this.context.services().get(0); + this.echoContext = TestProtoLoader.instance().parseShowcaseEcho(); + this.echoProtoService = this.echoContext.services().get(0); + this.echoGrpcRestContext = this.echoContext.toBuilder().setTransport(Transport.GRPC_REST).build(); + this.echoGrpcRestProtoService = this.echoGrpcRestContext.services().get(0); + this.echoRestContext = this.echoContext.toBuilder().setTransport(Transport.REST).build(); + this.echoRestProtoService = this.echoRestContext.services().get(0); this.wickedContext = GrpcRestTestProtoLoader.instance().parseShowcaseWicked(); this.wickedProtoService = this.wickedContext.services().get(0); } @Test public void generatePropertiesClazzGrpcTest() { + assertThat(this.echoContext.transport()).isEqualTo(Transport.GRPC); GapicClass clazz = - SpringPropertiesClassComposer.instance().generate(this.context, this.echoProtoService); + SpringPropertiesClassComposer.instance().generate(this.echoContext, this.echoProtoService); String fileName = clazz.classDefinition().classIdentifier() + "Grpc.golden"; Assert.assertGoldenClass(this.getClass(), clazz, fileName); } @Test public void generatePropertiesClazzGrpcRestTest() { - GapicContext contextGrpcRest = - this.context.toBuilder().setTransport(Transport.GRPC_REST).build(); + assertThat(this.echoGrpcRestContext.transport()).isEqualTo(Transport.GRPC_REST); GapicClass clazz = - SpringPropertiesClassComposer.instance().generate(contextGrpcRest, this.echoProtoService); + SpringPropertiesClassComposer.instance() + .generate(this.echoGrpcRestContext, this.echoGrpcRestProtoService); String fileName = clazz.classDefinition().classIdentifier() + "GrpcRest.golden"; Assert.assertGoldenClass(this.getClass(), clazz, fileName); } @Test public void generatePropertiesClazzNoRestRpcsTest() { - GapicContext contextGrpcRest = - this.wickedContext.toBuilder().setTransport(Transport.GRPC_REST).build(); + assertThat(this.wickedContext.transport()).isEqualTo(Transport.GRPC_REST); GapicClass clazz = - SpringPropertiesClassComposer.instance().generate(contextGrpcRest, this.wickedProtoService); + SpringPropertiesClassComposer.instance() + .generate(this.wickedContext, this.wickedProtoService); String fileName = clazz.classDefinition().classIdentifier() + "NoRestRpcs.golden"; Assert.assertGoldenClass(this.getClass(), clazz, fileName); } + + @Test + public void generatePropertiesClazzRestTest() { + assertThat(this.echoRestContext.transport()).isEqualTo(Transport.REST); + GapicClass clazz = + SpringPropertiesClassComposer.instance() + .generate(this.echoRestContext, this.echoRestProtoService); + String fileName = clazz.classDefinition().classIdentifier() + "Rest.golden"; + Assert.assertGoldenClass(this.getClass(), clazz, fileName); + } } diff --git a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationFull.golden b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationFull.golden index d6f58a7ac5..97f3de8aef 100644 --- a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationFull.golden +++ b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationFull.golden @@ -85,8 +85,10 @@ public class EchoSpringAutoConfiguration { } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationGrpc.golden b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationGrpc.golden index c3b708b68b..327fa50bf6 100644 --- a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationGrpc.golden +++ b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationGrpc.golden @@ -65,8 +65,10 @@ public class EchoSpringAutoConfiguration { } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationGrpcRest.golden b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationGrpcRest.golden index 50fd2c2bef..2d53a7ecc9 100644 --- a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationGrpcRest.golden +++ b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationGrpcRest.golden @@ -66,8 +66,10 @@ public class EchoSpringAutoConfiguration { } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationRest.golden b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationRest.golden new file mode 100644 index 0000000000..327fa50bf6 --- /dev/null +++ b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringAutoConfigurationRest.golden @@ -0,0 +1,232 @@ +package com.google.showcase.v1beta1.spring; + +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import com.google.showcase.v1beta1.EchoClient; +import com.google.showcase.v1beta1.EchoSettings; +import java.io.IOException; +import java.util.Collections; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link EchoClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(EchoClient.class) +@ConditionalOnProperty(value = "com.google.showcase.v1beta1.echo.enabled", matchIfMissing = true) +@EnableConfigurationProperties(EchoSpringProperties.class) +public class EchoSpringAutoConfiguration { + private final EchoSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(EchoSpringAutoConfiguration.class); + + protected EchoSpringAutoConfiguration( + EchoSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Echo-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultEchoTransportChannelProvider") + public TransportChannelProvider defaultEchoTransportChannelProvider() { + return EchoSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a EchoSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultEchoTransportChannelProvider()). It also + * configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in EchoSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link EchoSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public EchoSettings echoSettings( + @Qualifier("defaultEchoTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + EchoSettings.Builder clientSettingsBuilder = EchoSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + EchoSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings echoRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.echoSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.echoSettings().setRetrySettings(echoRetrySettings); + + RetrySettings pagedExpandRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.pagedExpandSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.pagedExpandSettings().setRetrySettings(pagedExpandRetrySettings); + + RetrySettings simplePagedExpandRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.simplePagedExpandSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .simplePagedExpandSettings() + .setRetrySettings(simplePagedExpandRetrySettings); + + RetrySettings blockRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.blockSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.blockSettings().setRetrySettings(blockRetrySettings); + + RetrySettings collideNameRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.collideNameSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.collideNameSettings().setRetrySettings(collideNameRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry echoRetry = clientProperties.getEchoRetry(); + if (echoRetry != null) { + RetrySettings echoRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.echoSettings().getRetrySettings(), echoRetry); + clientSettingsBuilder.echoSettings().setRetrySettings(echoRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for echo from properties."); + } + } + Retry pagedExpandRetry = clientProperties.getPagedExpandRetry(); + if (pagedExpandRetry != null) { + RetrySettings pagedExpandRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.pagedExpandSettings().getRetrySettings(), pagedExpandRetry); + clientSettingsBuilder.pagedExpandSettings().setRetrySettings(pagedExpandRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for pagedExpand from properties."); + } + } + Retry simplePagedExpandRetry = clientProperties.getSimplePagedExpandRetry(); + if (simplePagedExpandRetry != null) { + RetrySettings simplePagedExpandRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.simplePagedExpandSettings().getRetrySettings(), + simplePagedExpandRetry); + clientSettingsBuilder + .simplePagedExpandSettings() + .setRetrySettings(simplePagedExpandRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for simplePagedExpand from properties."); + } + } + Retry blockRetry = clientProperties.getBlockRetry(); + if (blockRetry != null) { + RetrySettings blockRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.blockSettings().getRetrySettings(), blockRetry); + clientSettingsBuilder.blockSettings().setRetrySettings(blockRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for block from properties."); + } + } + Retry collideNameRetry = clientProperties.getCollideNameRetry(); + if (collideNameRetry != null) { + RetrySettings collideNameRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.collideNameSettings().getRetrySettings(), collideNameRetry); + clientSettingsBuilder.collideNameSettings().setRetrySettings(collideNameRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for collideName from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a EchoClient bean configured with EchoSettings. + * + * @param echoSettings settings to configure an instance of client bean. + * @return a {@link EchoClient} bean configured with {@link EchoSettings} + */ + @Bean + @ConditionalOnMissingBean + public EchoClient echoClient(EchoSettings echoSettings) throws IOException { + return EchoClient.create(echoSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-echo"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringPropertiesRest.golden b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringPropertiesRest.golden new file mode 100644 index 0000000000..6b53f4ac6a --- /dev/null +++ b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/EchoSpringPropertiesRest.golden @@ -0,0 +1,117 @@ +package com.google.showcase.v1beta1.spring; + +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Echo client bean */ +@ConfigurationProperties("com.google.showcase.v1beta1.echo") +public class EchoSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials("https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for echo. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry echoRetry; + /** + * Allow override of retry settings at method-level for pagedExpand. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry pagedExpandRetry; + /** + * Allow override of retry settings at method-level for simplePagedExpand. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry simplePagedExpandRetry; + /** + * Allow override of retry settings at method-level for block. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry blockRetry; + /** + * Allow override of retry settings at method-level for collideName. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry collideNameRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getEchoRetry() { + return this.echoRetry; + } + + public void setEchoRetry(Retry echoRetry) { + this.echoRetry = echoRetry; + } + + public Retry getPagedExpandRetry() { + return this.pagedExpandRetry; + } + + public void setPagedExpandRetry(Retry pagedExpandRetry) { + this.pagedExpandRetry = pagedExpandRetry; + } + + public Retry getSimplePagedExpandRetry() { + return this.simplePagedExpandRetry; + } + + public void setSimplePagedExpandRetry(Retry simplePagedExpandRetry) { + this.simplePagedExpandRetry = simplePagedExpandRetry; + } + + public Retry getBlockRetry() { + return this.blockRetry; + } + + public void setBlockRetry(Retry blockRetry) { + this.blockRetry = blockRetry; + } + + public Retry getCollideNameRetry() { + return this.collideNameRetry; + } + + public void setCollideNameRetry(Retry collideNameRetry) { + this.collideNameRetry = collideNameRetry; + } +} diff --git a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/WickedSpringAutoConfigurationNoRestRpcs.golden b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/WickedSpringAutoConfigurationNoRestRpcs.golden index 9ee75624d0..7f4903693c 100644 --- a/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/WickedSpringAutoConfigurationNoRestRpcs.golden +++ b/spring-cloud-generator/src/test/java/com/google/cloud/generator/spring/composer/goldens/WickedSpringAutoConfigurationNoRestRpcs.golden @@ -65,8 +65,10 @@ public class WickedSpringAutoConfiguration { } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/README.md b/spring-cloud-previews/README.md index 2a0509b48e..9970dc02dd 100644 --- a/spring-cloud-previews/README.md +++ b/spring-cloud-previews/README.md @@ -34,6 +34,7 @@ add the following dependency to your `pom.xml`. |[java-binary-authorization](https://github.com/googleapis/google-cloud-java/blob/v1.12.0/java-binary-authorization/README.md)|com.google.cloud:google-cloud-binary-authorization-spring-starter| |[java-channel](https://github.com/googleapis/google-cloud-java/blob/v1.12.0/java-channel/README.md)|com.google.cloud:google-cloud-channel-spring-starter| |[java-cloudbuild](https://github.com/googleapis/google-cloud-java/blob/v1.12.0/java-cloudbuild/README.md)|com.google.cloud:google-cloud-build-spring-starter| +|[java-compute](https://github.com/googleapis/google-cloud-java/blob/v1.12.0/java-compute/README.md)|com.google.cloud:google-cloud-compute-spring-starter| |[java-contact-center-insights](https://github.com/googleapis/google-cloud-java/blob/v1.12.0/java-contact-center-insights/README.md)|com.google.cloud:google-cloud-contact-center-insights-spring-starter| |[java-container](https://github.com/googleapis/google-cloud-java/blob/v1.12.0/java-container/README.md)|com.google.cloud:google-cloud-container-spring-starter| |[java-containeranalysis](https://github.com/googleapis/google-cloud-java/blob/v1.12.0/java-containeranalysis/README.md)|com.google.cloud:google-cloud-containeranalysis-spring-starter| diff --git a/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/AccessApprovalSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/AccessApprovalSpringAutoConfiguration.java index bedc1a7860..a23d42d8e2 100644 --- a/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/AccessApprovalSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/AccessApprovalSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected AccessApprovalSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/AccessApprovalSpringProperties.java b/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/AccessApprovalSpringProperties.java index 5ec6b8cf57..8a8df5b6ed 100644 --- a/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/AccessApprovalSpringProperties.java +++ b/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/AccessApprovalSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/package-info.java index ff51d5f02a..4de920d31d 100644 --- a/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-accessapproval-spring-starter/src/main/java/com/google/cloud/accessapproval/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/DatasetServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/DatasetServiceSpringAutoConfiguration.java index 394cc961f9..b49bbdc606 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/DatasetServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/DatasetServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DatasetServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/DatasetServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/DatasetServiceSpringProperties.java index f3fc90613f..0a42633346 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/DatasetServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/DatasetServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/EndpointServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/EndpointServiceSpringAutoConfiguration.java index e15397860a..81b7fb04e3 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/EndpointServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/EndpointServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected EndpointServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/EndpointServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/EndpointServiceSpringProperties.java index d849c9b62b..458be876ac 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/EndpointServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/EndpointServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreOnlineServingServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreOnlineServingServiceSpringAutoConfiguration.java index 057b15ecc2..0932c2cc16 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreOnlineServingServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreOnlineServingServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,8 +89,10 @@ protected FeaturestoreOnlineServingServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreOnlineServingServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreOnlineServingServiceSpringProperties.java index a70d9eb823..8a38474f20 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreOnlineServingServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreOnlineServingServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreServiceSpringAutoConfiguration.java index 3d090affb0..4f968963bb 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected FeaturestoreServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreServiceSpringProperties.java index 4dbc497121..e3a4e696de 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/FeaturestoreServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexEndpointServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexEndpointServiceSpringAutoConfiguration.java index bc4e649908..c4295774e6 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexEndpointServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexEndpointServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected IndexEndpointServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexEndpointServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexEndpointServiceSpringProperties.java index be15a7850a..b8d442843b 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexEndpointServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexEndpointServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexServiceSpringAutoConfiguration.java index b326449313..39ca117b6f 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected IndexServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexServiceSpringProperties.java index b2c8cc11a7..ccc29f1f59 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/IndexServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/JobServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/JobServiceSpringAutoConfiguration.java index 3d419982a2..e3a5f0478a 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/JobServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/JobServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected JobServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/JobServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/JobServiceSpringProperties.java index 75c2ec2adf..8112a05f76 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/JobServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/JobServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MetadataServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MetadataServiceSpringAutoConfiguration.java index d2c105fb7e..e56cfa219b 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MetadataServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MetadataServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected MetadataServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MetadataServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MetadataServiceSpringProperties.java index 2ecbc76d04..261bee322b 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MetadataServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MetadataServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MigrationServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MigrationServiceSpringAutoConfiguration.java index 78f2f7f2f2..cdf51a939f 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MigrationServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MigrationServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected MigrationServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MigrationServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MigrationServiceSpringProperties.java index 3fd5eebd8f..d62672bb6e 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MigrationServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/MigrationServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/ModelServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/ModelServiceSpringAutoConfiguration.java index fc21fb6f2b..4b42ab1514 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/ModelServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/ModelServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ModelServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/ModelServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/ModelServiceSpringProperties.java index 9e51e4ec05..0036964f36 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/ModelServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/ModelServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PipelineServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PipelineServiceSpringAutoConfiguration.java index b151615ad6..a6eaa860cc 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PipelineServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PipelineServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected PipelineServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PipelineServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PipelineServiceSpringProperties.java index aeb513c29a..87c08cf8d1 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PipelineServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PipelineServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PredictionServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PredictionServiceSpringAutoConfiguration.java index e52f50d889..3f101d618f 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PredictionServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PredictionServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected PredictionServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PredictionServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PredictionServiceSpringProperties.java index 23c0914619..60fa2fda01 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PredictionServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/PredictionServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/SpecialistPoolServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/SpecialistPoolServiceSpringAutoConfiguration.java index 15e89f4323..7a4be1fc2e 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/SpecialistPoolServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/SpecialistPoolServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected SpecialistPoolServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/SpecialistPoolServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/SpecialistPoolServiceSpringProperties.java index 8fccbb95ac..61d41daf98 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/SpecialistPoolServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/SpecialistPoolServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/TensorboardServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/TensorboardServiceSpringAutoConfiguration.java index ad60ef435f..465365fd3e 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/TensorboardServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/TensorboardServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected TensorboardServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/TensorboardServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/TensorboardServiceSpringProperties.java index 60162e0b82..7cb702ee35 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/TensorboardServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/TensorboardServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/VizierServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/VizierServiceSpringAutoConfiguration.java index c3876fdbc8..a3a6ac1301 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/VizierServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/VizierServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected VizierServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/VizierServiceSpringProperties.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/VizierServiceSpringProperties.java index 9ceb07c35b..a94159a3ef 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/VizierServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/VizierServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/package-info.java index 4bfbb4cfb4..f2fda997ba 100644 --- a/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-aiplatform-spring-starter/src/main/java/com/google/cloud/aiplatform/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/ApiGatewayServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/ApiGatewayServiceSpringAutoConfiguration.java index d010c3e51d..eaa581468c 100644 --- a/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/ApiGatewayServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/ApiGatewayServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ApiGatewayServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/ApiGatewayServiceSpringProperties.java b/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/ApiGatewayServiceSpringProperties.java index f7da3b38e2..2b68ae7188 100644 --- a/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/ApiGatewayServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/ApiGatewayServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/package-info.java index 5ac7b04919..e597456cd0 100644 --- a/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-api-gateway-spring-starter/src/main/java/com/google/cloud/apigateway/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/ConnectionServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/ConnectionServiceSpringAutoConfiguration.java index 9ca00196c9..bbc803c726 100644 --- a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/ConnectionServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/ConnectionServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ConnectionServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/ConnectionServiceSpringProperties.java b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/ConnectionServiceSpringProperties.java index 36d1a28f0f..7812349931 100644 --- a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/ConnectionServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/ConnectionServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/TetherSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/TetherSpringAutoConfiguration.java index 81c6380be4..c5704083c2 100644 --- a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/TetherSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/TetherSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected TetherSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/TetherSpringProperties.java b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/TetherSpringProperties.java index c23ecc3d98..497357a072 100644 --- a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/TetherSpringProperties.java +++ b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/TetherSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/package-info.java index cf47d56217..166e32428c 100644 --- a/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-apigee-connect-spring-starter/src/main/java/com/google/cloud/apigeeconnect/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ApplicationsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ApplicationsSpringAutoConfiguration.java index 731eaf61ff..07d4b498a6 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ApplicationsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ApplicationsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ApplicationsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ApplicationsSpringProperties.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ApplicationsSpringProperties.java index c3b8460fb2..fba15ad5c9 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ApplicationsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ApplicationsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedCertificatesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedCertificatesSpringAutoConfiguration.java index 2676dba46a..12c569011a 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedCertificatesSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedCertificatesSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected AuthorizedCertificatesSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedCertificatesSpringProperties.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedCertificatesSpringProperties.java index bf3b1258ea..fa2e9063a3 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedCertificatesSpringProperties.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedCertificatesSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedDomainsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedDomainsSpringAutoConfiguration.java index d2630cda6a..a8c5d6418a 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedDomainsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedDomainsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected AuthorizedDomainsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedDomainsSpringProperties.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedDomainsSpringProperties.java index 90bf7ae7be..48ce801223 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedDomainsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/AuthorizedDomainsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/DomainMappingsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/DomainMappingsSpringAutoConfiguration.java index 36e952f820..da9e491913 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/DomainMappingsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/DomainMappingsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DomainMappingsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/DomainMappingsSpringProperties.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/DomainMappingsSpringProperties.java index 2c0a13fc6f..6b9d51c795 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/DomainMappingsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/DomainMappingsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/FirewallSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/FirewallSpringAutoConfiguration.java index 1728476a90..4404391ed8 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/FirewallSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/FirewallSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected FirewallSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/FirewallSpringProperties.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/FirewallSpringProperties.java index c9117f1b94..e19ec19f73 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/FirewallSpringProperties.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/FirewallSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/InstancesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/InstancesSpringAutoConfiguration.java index 362ee9bd7a..0f0892acdf 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/InstancesSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/InstancesSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected InstancesSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/InstancesSpringProperties.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/InstancesSpringProperties.java index 604b1feb44..1a1ab5f5ec 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/InstancesSpringProperties.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/InstancesSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ServicesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ServicesSpringAutoConfiguration.java index cd70359ca4..ed430c1c29 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ServicesSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ServicesSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected ServicesSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ServicesSpringProperties.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ServicesSpringProperties.java index fbca65af09..8168d8efdf 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ServicesSpringProperties.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/ServicesSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/VersionsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/VersionsSpringAutoConfiguration.java index dee770d69c..ff5e41d637 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/VersionsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/VersionsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected VersionsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/VersionsSpringProperties.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/VersionsSpringProperties.java index 8997c3d66c..461dff842a 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/VersionsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/VersionsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/package-info.java index 6a56713172..d24c59e081 100644 --- a/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-appengine-admin-spring-starter/src/main/java/com/google/appengine/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/ArtifactRegistrySpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/ArtifactRegistrySpringAutoConfiguration.java index b42174cd67..84346ed51f 100644 --- a/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/ArtifactRegistrySpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/ArtifactRegistrySpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ArtifactRegistrySpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/ArtifactRegistrySpringProperties.java b/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/ArtifactRegistrySpringProperties.java index 4d1f41b4a5..88bd5f852f 100644 --- a/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/ArtifactRegistrySpringProperties.java +++ b/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/ArtifactRegistrySpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/package-info.java index 97789f6a48..d00df0405b 100644 --- a/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-artifact-registry-spring-starter/src/main/java/com/google/devtools/artifactregistry/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/AssetServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/AssetServiceSpringAutoConfiguration.java index c97c6a9179..7bbfceaff9 100644 --- a/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/AssetServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/AssetServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected AssetServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/AssetServiceSpringProperties.java b/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/AssetServiceSpringProperties.java index 7edee6baae..88297eb450 100644 --- a/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/AssetServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/AssetServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/package-info.java index 562d0314e1..d95968111f 100644 --- a/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-asset-spring-starter/src/main/java/com/google/cloud/asset/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/AssuredWorkloadsServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/AssuredWorkloadsServiceSpringAutoConfiguration.java index 4e09928ff7..dc07ccd87e 100644 --- a/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/AssuredWorkloadsServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/AssuredWorkloadsServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected AssuredWorkloadsServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/AssuredWorkloadsServiceSpringProperties.java b/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/AssuredWorkloadsServiceSpringProperties.java index eccc217bb1..a5d26b4e56 100644 --- a/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/AssuredWorkloadsServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/AssuredWorkloadsServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/package-info.java index 24e8c0094a..3bb220b9ae 100644 --- a/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-assured-workloads-spring-starter/src/main/java/com/google/cloud/assuredworkloads/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/AutoMlSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/AutoMlSpringAutoConfiguration.java index a71032e444..0e633ec841 100644 --- a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/AutoMlSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/AutoMlSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected AutoMlSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/AutoMlSpringProperties.java b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/AutoMlSpringProperties.java index ec80b7c385..dd4022f449 100644 --- a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/AutoMlSpringProperties.java +++ b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/AutoMlSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/PredictionServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/PredictionServiceSpringAutoConfiguration.java index 563767fe32..f5e526925b 100644 --- a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/PredictionServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/PredictionServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected PredictionServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/PredictionServiceSpringProperties.java b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/PredictionServiceSpringProperties.java index ff19cad091..51cda3d74b 100644 --- a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/PredictionServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/PredictionServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/package-info.java index 82ff4cb0c9..d14526cec6 100644 --- a/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-automl-spring-starter/src/main/java/com/google/cloud/automl/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/ConnectionServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/ConnectionServiceSpringAutoConfiguration.java index 4e367e93d1..843f0e8752 100644 --- a/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/ConnectionServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/ConnectionServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ConnectionServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/ConnectionServiceSpringProperties.java b/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/ConnectionServiceSpringProperties.java index f7e2d7fe55..96d882f43d 100644 --- a/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/ConnectionServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/ConnectionServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/package-info.java index 4b43d90c8a..83c84e6a93 100644 --- a/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-bigqueryconnection-spring-starter/src/main/java/com/google/cloud/bigqueryconnection/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/DataTransferServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/DataTransferServiceSpringAutoConfiguration.java index e9abcd6a89..48c4878132 100644 --- a/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/DataTransferServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/DataTransferServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected DataTransferServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/DataTransferServiceSpringProperties.java b/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/DataTransferServiceSpringProperties.java index 5179acfc15..c16382de1d 100644 --- a/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/DataTransferServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/DataTransferServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/package-info.java index 51c69a1f9b..fbff4b3fe7 100644 --- a/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-bigquerydatatransfer-spring-starter/src/main/java/com/google/cloud/bigquery/datatransfer/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/ReservationServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/ReservationServiceSpringAutoConfiguration.java index 269c94a2d7..e1bd8f208e 100644 --- a/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/ReservationServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/ReservationServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ReservationServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/ReservationServiceSpringProperties.java b/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/ReservationServiceSpringProperties.java index a9f6a8d0ac..fda1d78947 100644 --- a/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/ReservationServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/ReservationServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/package-info.java index 9f6b121225..0dc37c1774 100644 --- a/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-bigqueryreservation-spring-starter/src/main/java/com/google/cloud/bigquery/reservation/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudBillingSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudBillingSpringAutoConfiguration.java index 362389077c..94296c0cea 100644 --- a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudBillingSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudBillingSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CloudBillingSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudBillingSpringProperties.java b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudBillingSpringProperties.java index 57bca339b5..8c53015c05 100644 --- a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudBillingSpringProperties.java +++ b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudBillingSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudCatalogSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudCatalogSpringAutoConfiguration.java index 95923e43d5..839891058e 100644 --- a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudCatalogSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudCatalogSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CloudCatalogSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudCatalogSpringProperties.java b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudCatalogSpringProperties.java index bf7f6e47b5..00ef70d713 100644 --- a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudCatalogSpringProperties.java +++ b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/CloudCatalogSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/package-info.java index 41a1551268..9031b74acc 100644 --- a/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-billing-spring-starter/src/main/java/com/google/cloud/billing/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/BudgetServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/BudgetServiceSpringAutoConfiguration.java index 5d6b226709..71ea95022e 100644 --- a/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/BudgetServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/BudgetServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected BudgetServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/BudgetServiceSpringProperties.java b/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/BudgetServiceSpringProperties.java index b1da8e8e49..48c13bb7c7 100644 --- a/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/BudgetServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/BudgetServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/package-info.java index 9811dd52f3..009dda3908 100644 --- a/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-billingbudgets-spring-starter/src/main/java/com/google/cloud/billing/budgets/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/BinauthzManagementServiceV1SpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/BinauthzManagementServiceV1SpringAutoConfiguration.java index 56fb763408..1a28588ff7 100644 --- a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/BinauthzManagementServiceV1SpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/BinauthzManagementServiceV1SpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -89,8 +89,10 @@ protected BinauthzManagementServiceV1SpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/BinauthzManagementServiceV1SpringProperties.java b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/BinauthzManagementServiceV1SpringProperties.java index b661d70ccb..f4883299f9 100644 --- a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/BinauthzManagementServiceV1SpringProperties.java +++ b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/BinauthzManagementServiceV1SpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/SystemPolicyV1SpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/SystemPolicyV1SpringAutoConfiguration.java index e95bbde717..0f00120b66 100644 --- a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/SystemPolicyV1SpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/SystemPolicyV1SpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected SystemPolicyV1SpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/SystemPolicyV1SpringProperties.java b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/SystemPolicyV1SpringProperties.java index 0b5973eb92..cec6548896 100644 --- a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/SystemPolicyV1SpringProperties.java +++ b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/SystemPolicyV1SpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/ValidationHelperV1SpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/ValidationHelperV1SpringAutoConfiguration.java index f8564674be..d4c1d777d9 100644 --- a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/ValidationHelperV1SpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/ValidationHelperV1SpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ValidationHelperV1SpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/ValidationHelperV1SpringProperties.java b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/ValidationHelperV1SpringProperties.java index 1e7761108b..a6fb768328 100644 --- a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/ValidationHelperV1SpringProperties.java +++ b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/ValidationHelperV1SpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/package-info.java index 575333b9bd..15f60ebefe 100644 --- a/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-binary-authorization-spring-starter/src/main/java/com/google/protos/google/cloud/binaryauthorization/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/RepositoryManagerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/RepositoryManagerSpringAutoConfiguration.java index a6be2580f1..77fa2b3f7c 100644 --- a/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/RepositoryManagerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/RepositoryManagerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected RepositoryManagerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/RepositoryManagerSpringProperties.java b/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/RepositoryManagerSpringProperties.java index d976137287..0fe34b4412 100644 --- a/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/RepositoryManagerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/RepositoryManagerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/package-info.java index 336f7561ab..4b55bc79f2 100644 --- a/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-build-spring-starter/src/main/java/com/google/cloud/devtools/cloudbuild/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelReportsServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelReportsServiceSpringAutoConfiguration.java index 7a5a2a5a00..22bc080467 100644 --- a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelReportsServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelReportsServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected CloudChannelReportsServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelReportsServiceSpringProperties.java b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelReportsServiceSpringProperties.java index 4baac0da1e..d14fa568a3 100644 --- a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelReportsServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelReportsServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelServiceSpringAutoConfiguration.java index e3a750770a..be0bab37e6 100644 --- a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected CloudChannelServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelServiceSpringProperties.java b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelServiceSpringProperties.java index 6db4ebaf6d..1719849269 100644 --- a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/CloudChannelServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/package-info.java index 8885f42071..2036c257e4 100644 --- a/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-channel-spring-starter/src/main/java/com/google/cloud/channel/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/pom.xml b/spring-cloud-previews/google-cloud-compute-spring-starter/pom.xml new file mode 100644 index 0000000000..91472a1589 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + + + com.google.cloud + spring-cloud-gcp-starters + 4.4.1-SNAPSHOT + ../../spring-cloud-gcp-starters/pom.xml + + google-cloud-compute-spring-starter + ${project.parent.version}-preview + Spring Boot Starter - compute + Spring Boot Starter with AutoConfiguration for compute + + + + + com.google.cloud + google-cloud-compute + + + + org.springframework.boot + spring-boot-starter + + + + com.google.cloud + spring-cloud-gcp-autoconfigure + + + + \ No newline at end of file diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AcceleratorTypesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AcceleratorTypesSpringAutoConfiguration.java new file mode 100644 index 0000000000..fb36df1630 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AcceleratorTypesSpringAutoConfiguration.java @@ -0,0 +1,223 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.AcceleratorTypesClient; +import com.google.cloud.compute.v1.AcceleratorTypesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link AcceleratorTypesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(AcceleratorTypesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.accelerator-types.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(AcceleratorTypesSpringProperties.class) +public class AcceleratorTypesSpringAutoConfiguration { + private final AcceleratorTypesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(AcceleratorTypesSpringAutoConfiguration.class); + + protected AcceleratorTypesSpringAutoConfiguration( + AcceleratorTypesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from AcceleratorTypes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultAcceleratorTypesTransportChannelProvider") + public TransportChannelProvider defaultAcceleratorTypesTransportChannelProvider() { + return AcceleratorTypesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a AcceleratorTypesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultAcceleratorTypesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in AcceleratorTypesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link AcceleratorTypesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public AcceleratorTypesSettings acceleratorTypesSettings( + @Qualifier("defaultAcceleratorTypesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + AcceleratorTypesSettings.Builder clientSettingsBuilder = AcceleratorTypesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + AcceleratorTypesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a AcceleratorTypesClient bean configured with AcceleratorTypesSettings. + * + * @param acceleratorTypesSettings settings to configure an instance of client bean. + * @return a {@link AcceleratorTypesClient} bean configured with {@link AcceleratorTypesSettings} + */ + @Bean + @ConditionalOnMissingBean + public AcceleratorTypesClient acceleratorTypesClient( + AcceleratorTypesSettings acceleratorTypesSettings) throws IOException { + return AcceleratorTypesClient.create(acceleratorTypesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-accelerator-types"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AcceleratorTypesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AcceleratorTypesSpringProperties.java new file mode 100644 index 0000000000..c6ecbf0de7 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AcceleratorTypesSpringProperties.java @@ -0,0 +1,114 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for AcceleratorTypes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.accelerator-types") +public class AcceleratorTypesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AddressesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AddressesSpringAutoConfiguration.java new file mode 100644 index 0000000000..cde1181625 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AddressesSpringAutoConfiguration.java @@ -0,0 +1,218 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.AddressesClient; +import com.google.cloud.compute.v1.AddressesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link AddressesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(AddressesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.addresses.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(AddressesSpringProperties.class) +public class AddressesSpringAutoConfiguration { + private final AddressesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(AddressesSpringAutoConfiguration.class); + + protected AddressesSpringAutoConfiguration( + AddressesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Addresses-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultAddressesTransportChannelProvider") + public TransportChannelProvider defaultAddressesTransportChannelProvider() { + return AddressesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a AddressesSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultAddressesTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in AddressesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link AddressesSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public AddressesSettings addressesSettings( + @Qualifier("defaultAddressesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + AddressesSettings.Builder clientSettingsBuilder = AddressesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + AddressesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a AddressesClient bean configured with AddressesSettings. + * + * @param addressesSettings settings to configure an instance of client bean. + * @return a {@link AddressesClient} bean configured with {@link AddressesSettings} + */ + @Bean + @ConditionalOnMissingBean + public AddressesClient addressesClient(AddressesSettings addressesSettings) throws IOException { + return AddressesClient.create(addressesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-addresses"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AddressesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AddressesSpringProperties.java new file mode 100644 index 0000000000..fc19311945 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AddressesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Addresses client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.addresses") +public class AddressesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AutoscalersSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AutoscalersSpringAutoConfiguration.java new file mode 100644 index 0000000000..03930d37b3 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AutoscalersSpringAutoConfiguration.java @@ -0,0 +1,221 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.AutoscalersClient; +import com.google.cloud.compute.v1.AutoscalersSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link AutoscalersClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(AutoscalersClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.autoscalers.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(AutoscalersSpringProperties.class) +public class AutoscalersSpringAutoConfiguration { + private final AutoscalersSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(AutoscalersSpringAutoConfiguration.class); + + protected AutoscalersSpringAutoConfiguration( + AutoscalersSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Autoscalers-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultAutoscalersTransportChannelProvider") + public TransportChannelProvider defaultAutoscalersTransportChannelProvider() { + return AutoscalersSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a AutoscalersSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultAutoscalersTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in AutoscalersSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link AutoscalersSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public AutoscalersSettings autoscalersSettings( + @Qualifier("defaultAutoscalersTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + AutoscalersSettings.Builder clientSettingsBuilder = AutoscalersSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + AutoscalersSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a AutoscalersClient bean configured with AutoscalersSettings. + * + * @param autoscalersSettings settings to configure an instance of client bean. + * @return a {@link AutoscalersClient} bean configured with {@link AutoscalersSettings} + */ + @Bean + @ConditionalOnMissingBean + public AutoscalersClient autoscalersClient(AutoscalersSettings autoscalersSettings) + throws IOException { + return AutoscalersClient.create(autoscalersSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-autoscalers"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AutoscalersSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AutoscalersSpringProperties.java new file mode 100644 index 0000000000..011068a4a1 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/AutoscalersSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Autoscalers client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.autoscalers") +public class AutoscalersSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendBucketsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendBucketsSpringAutoConfiguration.java new file mode 100644 index 0000000000..38c919ad58 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendBucketsSpringAutoConfiguration.java @@ -0,0 +1,206 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.BackendBucketsClient; +import com.google.cloud.compute.v1.BackendBucketsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link BackendBucketsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(BackendBucketsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.backend-buckets.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(BackendBucketsSpringProperties.class) +public class BackendBucketsSpringAutoConfiguration { + private final BackendBucketsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(BackendBucketsSpringAutoConfiguration.class); + + protected BackendBucketsSpringAutoConfiguration( + BackendBucketsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from BackendBuckets-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultBackendBucketsTransportChannelProvider") + public TransportChannelProvider defaultBackendBucketsTransportChannelProvider() { + return BackendBucketsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a BackendBucketsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultBackendBucketsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in BackendBucketsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link BackendBucketsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public BackendBucketsSettings backendBucketsSettings( + @Qualifier("defaultBackendBucketsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + BackendBucketsSettings.Builder clientSettingsBuilder = BackendBucketsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + BackendBucketsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a BackendBucketsClient bean configured with BackendBucketsSettings. + * + * @param backendBucketsSettings settings to configure an instance of client bean. + * @return a {@link BackendBucketsClient} bean configured with {@link BackendBucketsSettings} + */ + @Bean + @ConditionalOnMissingBean + public BackendBucketsClient backendBucketsClient(BackendBucketsSettings backendBucketsSettings) + throws IOException { + return BackendBucketsClient.create(backendBucketsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-backend-buckets"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendBucketsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendBucketsSpringProperties.java new file mode 100644 index 0000000000..ed534ddb37 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendBucketsSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for BackendBuckets client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.backend-buckets") +public class BackendBucketsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendServicesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendServicesSpringAutoConfiguration.java new file mode 100644 index 0000000000..fdc015c2bd --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendServicesSpringAutoConfiguration.java @@ -0,0 +1,267 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.BackendServicesClient; +import com.google.cloud.compute.v1.BackendServicesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link BackendServicesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(BackendServicesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.backend-services.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(BackendServicesSpringProperties.class) +public class BackendServicesSpringAutoConfiguration { + private final BackendServicesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(BackendServicesSpringAutoConfiguration.class); + + protected BackendServicesSpringAutoConfiguration( + BackendServicesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from BackendServices-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultBackendServicesTransportChannelProvider") + public TransportChannelProvider defaultBackendServicesTransportChannelProvider() { + return BackendServicesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a BackendServicesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultBackendServicesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in BackendServicesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link BackendServicesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public BackendServicesSettings backendServicesSettings( + @Qualifier("defaultBackendServicesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + BackendServicesSettings.Builder clientSettingsBuilder = BackendServicesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + BackendServicesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getHealthRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getHealthSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getHealthSettings().setRetrySettings(getHealthRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getHealthRetry = clientProperties.getGetHealthRetry(); + if (getHealthRetry != null) { + RetrySettings getHealthRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getHealthSettings().getRetrySettings(), getHealthRetry); + clientSettingsBuilder.getHealthSettings().setRetrySettings(getHealthRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getHealth from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a BackendServicesClient bean configured with BackendServicesSettings. + * + * @param backendServicesSettings settings to configure an instance of client bean. + * @return a {@link BackendServicesClient} bean configured with {@link BackendServicesSettings} + */ + @Bean + @ConditionalOnMissingBean + public BackendServicesClient backendServicesClient( + BackendServicesSettings backendServicesSettings) throws IOException { + return BackendServicesClient.create(backendServicesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-backend-services"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendServicesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendServicesSpringProperties.java new file mode 100644 index 0000000000..f75b47ae4e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/BackendServicesSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for BackendServices client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.backend-services") +public class BackendServicesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getHealth. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getHealthRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetHealthRetry() { + return this.getHealthRetry; + } + + public void setGetHealthRetry(Retry getHealthRetry) { + this.getHealthRetry = getHealthRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DiskTypesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DiskTypesSpringAutoConfiguration.java new file mode 100644 index 0000000000..7c1d02085e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DiskTypesSpringAutoConfiguration.java @@ -0,0 +1,218 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.DiskTypesClient; +import com.google.cloud.compute.v1.DiskTypesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link DiskTypesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(DiskTypesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.disk-types.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(DiskTypesSpringProperties.class) +public class DiskTypesSpringAutoConfiguration { + private final DiskTypesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(DiskTypesSpringAutoConfiguration.class); + + protected DiskTypesSpringAutoConfiguration( + DiskTypesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from DiskTypes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultDiskTypesTransportChannelProvider") + public TransportChannelProvider defaultDiskTypesTransportChannelProvider() { + return DiskTypesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a DiskTypesSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultDiskTypesTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in DiskTypesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link DiskTypesSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public DiskTypesSettings diskTypesSettings( + @Qualifier("defaultDiskTypesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + DiskTypesSettings.Builder clientSettingsBuilder = DiskTypesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + DiskTypesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a DiskTypesClient bean configured with DiskTypesSettings. + * + * @param diskTypesSettings settings to configure an instance of client bean. + * @return a {@link DiskTypesClient} bean configured with {@link DiskTypesSettings} + */ + @Bean + @ConditionalOnMissingBean + public DiskTypesClient diskTypesClient(DiskTypesSettings diskTypesSettings) throws IOException { + return DiskTypesClient.create(diskTypesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-disk-types"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DiskTypesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DiskTypesSpringProperties.java new file mode 100644 index 0000000000..b0ac238a84 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DiskTypesSpringProperties.java @@ -0,0 +1,114 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for DiskTypes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.disk-types") +public class DiskTypesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DisksSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DisksSpringAutoConfiguration.java new file mode 100644 index 0000000000..c7614f4627 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DisksSpringAutoConfiguration.java @@ -0,0 +1,267 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.DisksClient; +import com.google.cloud.compute.v1.DisksSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link DisksClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(DisksClient.class) +@ConditionalOnProperty(value = "com.google.cloud.compute.v1.disks.enabled", matchIfMissing = true) +@EnableConfigurationProperties(DisksSpringProperties.class) +public class DisksSpringAutoConfiguration { + private final DisksSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(DisksSpringAutoConfiguration.class); + + protected DisksSpringAutoConfiguration( + DisksSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Disks-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultDisksTransportChannelProvider") + public TransportChannelProvider defaultDisksTransportChannelProvider() { + return DisksSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a DisksSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultDisksTransportChannelProvider()). It also + * configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in DisksSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link DisksSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public DisksSettings disksSettings( + @Qualifier("defaultDisksTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + DisksSettings.Builder clientSettingsBuilder = DisksSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + DisksSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a DisksClient bean configured with DisksSettings. + * + * @param disksSettings settings to configure an instance of client bean. + * @return a {@link DisksClient} bean configured with {@link DisksSettings} + */ + @Bean + @ConditionalOnMissingBean + public DisksClient disksClient(DisksSettings disksSettings) throws IOException { + return DisksClient.create(disksSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-disks"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DisksSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DisksSpringProperties.java new file mode 100644 index 0000000000..a3dda7442b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/DisksSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Disks client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.disks") +public class DisksSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ExternalVpnGatewaysSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ExternalVpnGatewaysSpringAutoConfiguration.java new file mode 100644 index 0000000000..8e47cd8baf --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ExternalVpnGatewaysSpringAutoConfiguration.java @@ -0,0 +1,230 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ExternalVpnGatewaysClient; +import com.google.cloud.compute.v1.ExternalVpnGatewaysSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ExternalVpnGatewaysClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ExternalVpnGatewaysClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.external-vpn-gateways.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(ExternalVpnGatewaysSpringProperties.class) +public class ExternalVpnGatewaysSpringAutoConfiguration { + private final ExternalVpnGatewaysSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(ExternalVpnGatewaysSpringAutoConfiguration.class); + + protected ExternalVpnGatewaysSpringAutoConfiguration( + ExternalVpnGatewaysSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from ExternalVpnGateways-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultExternalVpnGatewaysTransportChannelProvider") + public TransportChannelProvider defaultExternalVpnGatewaysTransportChannelProvider() { + return ExternalVpnGatewaysSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ExternalVpnGatewaysSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultExternalVpnGatewaysTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ExternalVpnGatewaysSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ExternalVpnGatewaysSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public ExternalVpnGatewaysSettings externalVpnGatewaysSettings( + @Qualifier("defaultExternalVpnGatewaysTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ExternalVpnGatewaysSettings.Builder clientSettingsBuilder = + ExternalVpnGatewaysSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ExternalVpnGatewaysSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ExternalVpnGatewaysClient bean configured with ExternalVpnGatewaysSettings. + * + * @param externalVpnGatewaysSettings settings to configure an instance of client bean. + * @return a {@link ExternalVpnGatewaysClient} bean configured with {@link + * ExternalVpnGatewaysSettings} + */ + @Bean + @ConditionalOnMissingBean + public ExternalVpnGatewaysClient externalVpnGatewaysClient( + ExternalVpnGatewaysSettings externalVpnGatewaysSettings) throws IOException { + return ExternalVpnGatewaysClient.create(externalVpnGatewaysSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-external-vpn-gateways"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ExternalVpnGatewaysSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ExternalVpnGatewaysSpringProperties.java new file mode 100644 index 0000000000..8c6821ca59 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ExternalVpnGatewaysSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for ExternalVpnGateways client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.external-vpn-gateways") +public class ExternalVpnGatewaysSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallPoliciesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallPoliciesSpringAutoConfiguration.java new file mode 100644 index 0000000000..7b8eeacdfe --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallPoliciesSpringAutoConfiguration.java @@ -0,0 +1,310 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.FirewallPoliciesClient; +import com.google.cloud.compute.v1.FirewallPoliciesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link FirewallPoliciesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(FirewallPoliciesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.firewall-policies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(FirewallPoliciesSpringProperties.class) +public class FirewallPoliciesSpringAutoConfiguration { + private final FirewallPoliciesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(FirewallPoliciesSpringAutoConfiguration.class); + + protected FirewallPoliciesSpringAutoConfiguration( + FirewallPoliciesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from FirewallPolicies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultFirewallPoliciesTransportChannelProvider") + public TransportChannelProvider defaultFirewallPoliciesTransportChannelProvider() { + return FirewallPoliciesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a FirewallPoliciesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultFirewallPoliciesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in FirewallPoliciesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link FirewallPoliciesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public FirewallPoliciesSettings firewallPoliciesSettings( + @Qualifier("defaultFirewallPoliciesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + FirewallPoliciesSettings.Builder clientSettingsBuilder = FirewallPoliciesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + FirewallPoliciesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getAssociationRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getAssociationSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getAssociationSettings().setRetrySettings(getAssociationRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings getRuleRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRuleSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getRuleSettings().setRetrySettings(getRuleRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listAssociationsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listAssociationsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .listAssociationsSettings() + .setRetrySettings(listAssociationsRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getAssociationRetry = clientProperties.getGetAssociationRetry(); + if (getAssociationRetry != null) { + RetrySettings getAssociationRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getAssociationSettings().getRetrySettings(), + getAssociationRetry); + clientSettingsBuilder.getAssociationSettings().setRetrySettings(getAssociationRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getAssociation from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry getRuleRetry = clientProperties.getGetRuleRetry(); + if (getRuleRetry != null) { + RetrySettings getRuleRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRuleSettings().getRetrySettings(), getRuleRetry); + clientSettingsBuilder.getRuleSettings().setRetrySettings(getRuleRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getRule from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listAssociationsRetry = clientProperties.getListAssociationsRetry(); + if (listAssociationsRetry != null) { + RetrySettings listAssociationsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listAssociationsSettings().getRetrySettings(), + listAssociationsRetry); + clientSettingsBuilder + .listAssociationsSettings() + .setRetrySettings(listAssociationsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listAssociations from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a FirewallPoliciesClient bean configured with FirewallPoliciesSettings. + * + * @param firewallPoliciesSettings settings to configure an instance of client bean. + * @return a {@link FirewallPoliciesClient} bean configured with {@link FirewallPoliciesSettings} + */ + @Bean + @ConditionalOnMissingBean + public FirewallPoliciesClient firewallPoliciesClient( + FirewallPoliciesSettings firewallPoliciesSettings) throws IOException { + return FirewallPoliciesClient.create(firewallPoliciesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-firewall-policies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallPoliciesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallPoliciesSpringProperties.java new file mode 100644 index 0000000000..7d46a14cce --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallPoliciesSpringProperties.java @@ -0,0 +1,178 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for FirewallPolicies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.firewall-policies") +public class FirewallPoliciesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getAssociation. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getAssociationRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for getRule. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRuleRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listAssociations. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listAssociationsRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetAssociationRetry() { + return this.getAssociationRetry; + } + + public void setGetAssociationRetry(Retry getAssociationRetry) { + this.getAssociationRetry = getAssociationRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getGetRuleRetry() { + return this.getRuleRetry; + } + + public void setGetRuleRetry(Retry getRuleRetry) { + this.getRuleRetry = getRuleRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListAssociationsRetry() { + return this.listAssociationsRetry; + } + + public void setListAssociationsRetry(Retry listAssociationsRetry) { + this.listAssociationsRetry = listAssociationsRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallsSpringAutoConfiguration.java new file mode 100644 index 0000000000..eba19f59b2 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallsSpringAutoConfiguration.java @@ -0,0 +1,202 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.FirewallsClient; +import com.google.cloud.compute.v1.FirewallsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link FirewallsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(FirewallsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.firewalls.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(FirewallsSpringProperties.class) +public class FirewallsSpringAutoConfiguration { + private final FirewallsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(FirewallsSpringAutoConfiguration.class); + + protected FirewallsSpringAutoConfiguration( + FirewallsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Firewalls-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultFirewallsTransportChannelProvider") + public TransportChannelProvider defaultFirewallsTransportChannelProvider() { + return FirewallsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a FirewallsSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultFirewallsTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in FirewallsSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link FirewallsSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public FirewallsSettings firewallsSettings( + @Qualifier("defaultFirewallsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + FirewallsSettings.Builder clientSettingsBuilder = FirewallsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + FirewallsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a FirewallsClient bean configured with FirewallsSettings. + * + * @param firewallsSettings settings to configure an instance of client bean. + * @return a {@link FirewallsClient} bean configured with {@link FirewallsSettings} + */ + @Bean + @ConditionalOnMissingBean + public FirewallsClient firewallsClient(FirewallsSettings firewallsSettings) throws IOException { + return FirewallsClient.create(firewallsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-firewalls"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallsSpringProperties.java new file mode 100644 index 0000000000..da08332539 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/FirewallsSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Firewalls client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.firewalls") +public class FirewallsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ForwardingRulesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ForwardingRulesSpringAutoConfiguration.java new file mode 100644 index 0000000000..95f852822e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ForwardingRulesSpringAutoConfiguration.java @@ -0,0 +1,222 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ForwardingRulesClient; +import com.google.cloud.compute.v1.ForwardingRulesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ForwardingRulesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ForwardingRulesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.forwarding-rules.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(ForwardingRulesSpringProperties.class) +public class ForwardingRulesSpringAutoConfiguration { + private final ForwardingRulesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(ForwardingRulesSpringAutoConfiguration.class); + + protected ForwardingRulesSpringAutoConfiguration( + ForwardingRulesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from ForwardingRules-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultForwardingRulesTransportChannelProvider") + public TransportChannelProvider defaultForwardingRulesTransportChannelProvider() { + return ForwardingRulesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ForwardingRulesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultForwardingRulesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ForwardingRulesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ForwardingRulesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public ForwardingRulesSettings forwardingRulesSettings( + @Qualifier("defaultForwardingRulesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ForwardingRulesSettings.Builder clientSettingsBuilder = ForwardingRulesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ForwardingRulesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ForwardingRulesClient bean configured with ForwardingRulesSettings. + * + * @param forwardingRulesSettings settings to configure an instance of client bean. + * @return a {@link ForwardingRulesClient} bean configured with {@link ForwardingRulesSettings} + */ + @Bean + @ConditionalOnMissingBean + public ForwardingRulesClient forwardingRulesClient( + ForwardingRulesSettings forwardingRulesSettings) throws IOException { + return ForwardingRulesClient.create(forwardingRulesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-forwarding-rules"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ForwardingRulesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ForwardingRulesSpringProperties.java new file mode 100644 index 0000000000..a5a0f72f40 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ForwardingRulesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for ForwardingRules client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.forwarding-rules") +public class ForwardingRulesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalAddressesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalAddressesSpringAutoConfiguration.java new file mode 100644 index 0000000000..c257ad144e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalAddressesSpringAutoConfiguration.java @@ -0,0 +1,206 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.GlobalAddressesClient; +import com.google.cloud.compute.v1.GlobalAddressesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link GlobalAddressesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(GlobalAddressesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.global-addresses.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(GlobalAddressesSpringProperties.class) +public class GlobalAddressesSpringAutoConfiguration { + private final GlobalAddressesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(GlobalAddressesSpringAutoConfiguration.class); + + protected GlobalAddressesSpringAutoConfiguration( + GlobalAddressesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from GlobalAddresses-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultGlobalAddressesTransportChannelProvider") + public TransportChannelProvider defaultGlobalAddressesTransportChannelProvider() { + return GlobalAddressesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a GlobalAddressesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultGlobalAddressesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in GlobalAddressesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link GlobalAddressesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public GlobalAddressesSettings globalAddressesSettings( + @Qualifier("defaultGlobalAddressesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + GlobalAddressesSettings.Builder clientSettingsBuilder = GlobalAddressesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + GlobalAddressesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a GlobalAddressesClient bean configured with GlobalAddressesSettings. + * + * @param globalAddressesSettings settings to configure an instance of client bean. + * @return a {@link GlobalAddressesClient} bean configured with {@link GlobalAddressesSettings} + */ + @Bean + @ConditionalOnMissingBean + public GlobalAddressesClient globalAddressesClient( + GlobalAddressesSettings globalAddressesSettings) throws IOException { + return GlobalAddressesClient.create(globalAddressesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-global-addresses"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalAddressesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalAddressesSpringProperties.java new file mode 100644 index 0000000000..4507aa3ff5 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalAddressesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for GlobalAddresses client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.global-addresses") +public class GlobalAddressesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalForwardingRulesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalForwardingRulesSpringAutoConfiguration.java new file mode 100644 index 0000000000..d3e4caa62d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalForwardingRulesSpringAutoConfiguration.java @@ -0,0 +1,210 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.GlobalForwardingRulesClient; +import com.google.cloud.compute.v1.GlobalForwardingRulesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link GlobalForwardingRulesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(GlobalForwardingRulesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.global-forwarding-rules.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(GlobalForwardingRulesSpringProperties.class) +public class GlobalForwardingRulesSpringAutoConfiguration { + private final GlobalForwardingRulesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(GlobalForwardingRulesSpringAutoConfiguration.class); + + protected GlobalForwardingRulesSpringAutoConfiguration( + GlobalForwardingRulesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from GlobalForwardingRules-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultGlobalForwardingRulesTransportChannelProvider") + public TransportChannelProvider defaultGlobalForwardingRulesTransportChannelProvider() { + return GlobalForwardingRulesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a GlobalForwardingRulesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultGlobalForwardingRulesTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in GlobalForwardingRulesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link GlobalForwardingRulesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public GlobalForwardingRulesSettings globalForwardingRulesSettings( + @Qualifier("defaultGlobalForwardingRulesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + GlobalForwardingRulesSettings.Builder clientSettingsBuilder = + GlobalForwardingRulesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + GlobalForwardingRulesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a GlobalForwardingRulesClient bean configured with GlobalForwardingRulesSettings. + * + * @param globalForwardingRulesSettings settings to configure an instance of client bean. + * @return a {@link GlobalForwardingRulesClient} bean configured with {@link + * GlobalForwardingRulesSettings} + */ + @Bean + @ConditionalOnMissingBean + public GlobalForwardingRulesClient globalForwardingRulesClient( + GlobalForwardingRulesSettings globalForwardingRulesSettings) throws IOException { + return GlobalForwardingRulesClient.create(globalForwardingRulesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-global-forwarding-rules"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalForwardingRulesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalForwardingRulesSpringProperties.java new file mode 100644 index 0000000000..449222018e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalForwardingRulesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for GlobalForwardingRules client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.global-forwarding-rules") +public class GlobalForwardingRulesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalNetworkEndpointGroupsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalNetworkEndpointGroupsSpringAutoConfiguration.java new file mode 100644 index 0000000000..8509dc987c --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalNetworkEndpointGroupsSpringAutoConfiguration.java @@ -0,0 +1,233 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.GlobalNetworkEndpointGroupsClient; +import com.google.cloud.compute.v1.GlobalNetworkEndpointGroupsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link GlobalNetworkEndpointGroupsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(GlobalNetworkEndpointGroupsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.global-network-endpoint-groups.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(GlobalNetworkEndpointGroupsSpringProperties.class) +public class GlobalNetworkEndpointGroupsSpringAutoConfiguration { + private final GlobalNetworkEndpointGroupsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(GlobalNetworkEndpointGroupsSpringAutoConfiguration.class); + + protected GlobalNetworkEndpointGroupsSpringAutoConfiguration( + GlobalNetworkEndpointGroupsSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from GlobalNetworkEndpointGroups-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultGlobalNetworkEndpointGroupsTransportChannelProvider") + public TransportChannelProvider defaultGlobalNetworkEndpointGroupsTransportChannelProvider() { + return GlobalNetworkEndpointGroupsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a GlobalNetworkEndpointGroupsSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultGlobalNetworkEndpointGroupsTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in GlobalNetworkEndpointGroupsSpringProperties. Method-level properties will take precedence + * over service-level properties if available, and client library defaults will be used if neither + * are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link GlobalNetworkEndpointGroupsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public GlobalNetworkEndpointGroupsSettings globalNetworkEndpointGroupsSettings( + @Qualifier("defaultGlobalNetworkEndpointGroupsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + GlobalNetworkEndpointGroupsSettings.Builder clientSettingsBuilder = + GlobalNetworkEndpointGroupsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + GlobalNetworkEndpointGroupsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listNetworkEndpointsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listNetworkEndpointsSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listNetworkEndpointsSettings() + .setRetrySettings(listNetworkEndpointsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listNetworkEndpointsRetry = clientProperties.getListNetworkEndpointsRetry(); + if (listNetworkEndpointsRetry != null) { + RetrySettings listNetworkEndpointsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listNetworkEndpointsSettings().getRetrySettings(), + listNetworkEndpointsRetry); + clientSettingsBuilder + .listNetworkEndpointsSettings() + .setRetrySettings(listNetworkEndpointsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listNetworkEndpoints from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a GlobalNetworkEndpointGroupsClient bean configured with + * GlobalNetworkEndpointGroupsSettings. + * + * @param globalNetworkEndpointGroupsSettings settings to configure an instance of client bean. + * @return a {@link GlobalNetworkEndpointGroupsClient} bean configured with {@link + * GlobalNetworkEndpointGroupsSettings} + */ + @Bean + @ConditionalOnMissingBean + public GlobalNetworkEndpointGroupsClient globalNetworkEndpointGroupsClient( + GlobalNetworkEndpointGroupsSettings globalNetworkEndpointGroupsSettings) throws IOException { + return GlobalNetworkEndpointGroupsClient.create(globalNetworkEndpointGroupsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-global-network-endpoint-groups"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalNetworkEndpointGroupsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalNetworkEndpointGroupsSpringProperties.java new file mode 100644 index 0000000000..a2e3d3a62e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalNetworkEndpointGroupsSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for GlobalNetworkEndpointGroups client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.global-network-endpoint-groups") +public class GlobalNetworkEndpointGroupsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listNetworkEndpoints. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listNetworkEndpointsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListNetworkEndpointsRetry() { + return this.listNetworkEndpointsRetry; + } + + public void setListNetworkEndpointsRetry(Retry listNetworkEndpointsRetry) { + this.listNetworkEndpointsRetry = listNetworkEndpointsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOperationsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOperationsSpringAutoConfiguration.java new file mode 100644 index 0000000000..befade9f05 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOperationsSpringAutoConfiguration.java @@ -0,0 +1,253 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.GlobalOperationsClient; +import com.google.cloud.compute.v1.GlobalOperationsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link GlobalOperationsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(GlobalOperationsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.global-operations.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(GlobalOperationsSpringProperties.class) +public class GlobalOperationsSpringAutoConfiguration { + private final GlobalOperationsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(GlobalOperationsSpringAutoConfiguration.class); + + protected GlobalOperationsSpringAutoConfiguration( + GlobalOperationsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from GlobalOperations-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultGlobalOperationsTransportChannelProvider") + public TransportChannelProvider defaultGlobalOperationsTransportChannelProvider() { + return GlobalOperationsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a GlobalOperationsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultGlobalOperationsTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in GlobalOperationsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link GlobalOperationsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public GlobalOperationsSettings globalOperationsSettings( + @Qualifier("defaultGlobalOperationsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + GlobalOperationsSettings.Builder clientSettingsBuilder = GlobalOperationsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + GlobalOperationsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings deleteRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.deleteSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.deleteSettings().setRetrySettings(deleteRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings waitRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.waitSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.waitSettings().setRetrySettings(waitRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry deleteRetry = clientProperties.getDeleteRetry(); + if (deleteRetry != null) { + RetrySettings deleteRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.deleteSettings().getRetrySettings(), deleteRetry); + clientSettingsBuilder.deleteSettings().setRetrySettings(deleteRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for delete from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry waitRetry = clientProperties.getWaitRetry(); + if (waitRetry != null) { + RetrySettings waitRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.waitSettings().getRetrySettings(), waitRetry); + clientSettingsBuilder.waitSettings().setRetrySettings(waitRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for wait from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a GlobalOperationsClient bean configured with GlobalOperationsSettings. + * + * @param globalOperationsSettings settings to configure an instance of client bean. + * @return a {@link GlobalOperationsClient} bean configured with {@link GlobalOperationsSettings} + */ + @Bean + @ConditionalOnMissingBean + public GlobalOperationsClient globalOperationsClient( + GlobalOperationsSettings globalOperationsSettings) throws IOException { + return GlobalOperationsClient.create(globalOperationsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-global-operations"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOperationsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOperationsSpringProperties.java new file mode 100644 index 0000000000..4e1e6421a4 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOperationsSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for GlobalOperations client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.global-operations") +public class GlobalOperationsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for delete. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry deleteRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for wait. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry waitRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getDeleteRetry() { + return this.deleteRetry; + } + + public void setDeleteRetry(Retry deleteRetry) { + this.deleteRetry = deleteRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getWaitRetry() { + return this.waitRetry; + } + + public void setWaitRetry(Retry waitRetry) { + this.waitRetry = waitRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOrganizationOperationsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOrganizationOperationsSpringAutoConfiguration.java new file mode 100644 index 0000000000..7054446a78 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOrganizationOperationsSpringAutoConfiguration.java @@ -0,0 +1,227 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.GlobalOrganizationOperationsClient; +import com.google.cloud.compute.v1.GlobalOrganizationOperationsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link GlobalOrganizationOperationsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(GlobalOrganizationOperationsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.global-organization-operations.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(GlobalOrganizationOperationsSpringProperties.class) +public class GlobalOrganizationOperationsSpringAutoConfiguration { + private final GlobalOrganizationOperationsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(GlobalOrganizationOperationsSpringAutoConfiguration.class); + + protected GlobalOrganizationOperationsSpringAutoConfiguration( + GlobalOrganizationOperationsSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from GlobalOrganizationOperations-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultGlobalOrganizationOperationsTransportChannelProvider") + public TransportChannelProvider defaultGlobalOrganizationOperationsTransportChannelProvider() { + return GlobalOrganizationOperationsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a GlobalOrganizationOperationsSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultGlobalOrganizationOperationsTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in GlobalOrganizationOperationsSpringProperties. Method-level properties will take precedence + * over service-level properties if available, and client library defaults will be used if neither + * are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link GlobalOrganizationOperationsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public GlobalOrganizationOperationsSettings globalOrganizationOperationsSettings( + @Qualifier("defaultGlobalOrganizationOperationsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + GlobalOrganizationOperationsSettings.Builder clientSettingsBuilder = + GlobalOrganizationOperationsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + GlobalOrganizationOperationsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings deleteRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.deleteSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.deleteSettings().setRetrySettings(deleteRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry deleteRetry = clientProperties.getDeleteRetry(); + if (deleteRetry != null) { + RetrySettings deleteRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.deleteSettings().getRetrySettings(), deleteRetry); + clientSettingsBuilder.deleteSettings().setRetrySettings(deleteRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for delete from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a GlobalOrganizationOperationsClient bean configured with + * GlobalOrganizationOperationsSettings. + * + * @param globalOrganizationOperationsSettings settings to configure an instance of client bean. + * @return a {@link GlobalOrganizationOperationsClient} bean configured with {@link + * GlobalOrganizationOperationsSettings} + */ + @Bean + @ConditionalOnMissingBean + public GlobalOrganizationOperationsClient globalOrganizationOperationsClient( + GlobalOrganizationOperationsSettings globalOrganizationOperationsSettings) + throws IOException { + return GlobalOrganizationOperationsClient.create(globalOrganizationOperationsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-global-organization-operations"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOrganizationOperationsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOrganizationOperationsSpringProperties.java new file mode 100644 index 0000000000..7ff03d948d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalOrganizationOperationsSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for GlobalOrganizationOperations client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.global-organization-operations") +public class GlobalOrganizationOperationsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for delete. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry deleteRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getDeleteRetry() { + return this.deleteRetry; + } + + public void setDeleteRetry(Retry deleteRetry) { + this.deleteRetry = deleteRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalPublicDelegatedPrefixesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalPublicDelegatedPrefixesSpringAutoConfiguration.java new file mode 100644 index 0000000000..ba031f4f73 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalPublicDelegatedPrefixesSpringAutoConfiguration.java @@ -0,0 +1,212 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.GlobalPublicDelegatedPrefixesClient; +import com.google.cloud.compute.v1.GlobalPublicDelegatedPrefixesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link GlobalPublicDelegatedPrefixesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(GlobalPublicDelegatedPrefixesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.global-public-delegated-prefixes.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(GlobalPublicDelegatedPrefixesSpringProperties.class) +public class GlobalPublicDelegatedPrefixesSpringAutoConfiguration { + private final GlobalPublicDelegatedPrefixesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(GlobalPublicDelegatedPrefixesSpringAutoConfiguration.class); + + protected GlobalPublicDelegatedPrefixesSpringAutoConfiguration( + GlobalPublicDelegatedPrefixesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from GlobalPublicDelegatedPrefixes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultGlobalPublicDelegatedPrefixesTransportChannelProvider") + public TransportChannelProvider defaultGlobalPublicDelegatedPrefixesTransportChannelProvider() { + return GlobalPublicDelegatedPrefixesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a GlobalPublicDelegatedPrefixesSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultGlobalPublicDelegatedPrefixesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in GlobalPublicDelegatedPrefixesSpringProperties. Method-level properties will take precedence + * over service-level properties if available, and client library defaults will be used if neither + * are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link GlobalPublicDelegatedPrefixesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public GlobalPublicDelegatedPrefixesSettings globalPublicDelegatedPrefixesSettings( + @Qualifier("defaultGlobalPublicDelegatedPrefixesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + GlobalPublicDelegatedPrefixesSettings.Builder clientSettingsBuilder = + GlobalPublicDelegatedPrefixesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + GlobalPublicDelegatedPrefixesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a GlobalPublicDelegatedPrefixesClient bean configured with + * GlobalPublicDelegatedPrefixesSettings. + * + * @param globalPublicDelegatedPrefixesSettings settings to configure an instance of client bean. + * @return a {@link GlobalPublicDelegatedPrefixesClient} bean configured with {@link + * GlobalPublicDelegatedPrefixesSettings} + */ + @Bean + @ConditionalOnMissingBean + public GlobalPublicDelegatedPrefixesClient globalPublicDelegatedPrefixesClient( + GlobalPublicDelegatedPrefixesSettings globalPublicDelegatedPrefixesSettings) + throws IOException { + return GlobalPublicDelegatedPrefixesClient.create(globalPublicDelegatedPrefixesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-global-public-delegated-prefixes"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalPublicDelegatedPrefixesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalPublicDelegatedPrefixesSpringProperties.java new file mode 100644 index 0000000000..7a2ef477b1 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/GlobalPublicDelegatedPrefixesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for GlobalPublicDelegatedPrefixes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.global-public-delegated-prefixes") +public class GlobalPublicDelegatedPrefixesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/HealthChecksSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/HealthChecksSpringAutoConfiguration.java new file mode 100644 index 0000000000..208828b512 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/HealthChecksSpringAutoConfiguration.java @@ -0,0 +1,222 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.HealthChecksClient; +import com.google.cloud.compute.v1.HealthChecksSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link HealthChecksClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(HealthChecksClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.health-checks.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(HealthChecksSpringProperties.class) +public class HealthChecksSpringAutoConfiguration { + private final HealthChecksSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(HealthChecksSpringAutoConfiguration.class); + + protected HealthChecksSpringAutoConfiguration( + HealthChecksSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from HealthChecks-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultHealthChecksTransportChannelProvider") + public TransportChannelProvider defaultHealthChecksTransportChannelProvider() { + return HealthChecksSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a HealthChecksSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultHealthChecksTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in HealthChecksSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link HealthChecksSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public HealthChecksSettings healthChecksSettings( + @Qualifier("defaultHealthChecksTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + HealthChecksSettings.Builder clientSettingsBuilder = HealthChecksSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + HealthChecksSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a HealthChecksClient bean configured with HealthChecksSettings. + * + * @param healthChecksSettings settings to configure an instance of client bean. + * @return a {@link HealthChecksClient} bean configured with {@link HealthChecksSettings} + */ + @Bean + @ConditionalOnMissingBean + public HealthChecksClient healthChecksClient(HealthChecksSettings healthChecksSettings) + throws IOException { + return HealthChecksClient.create(healthChecksSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-health-checks"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/HealthChecksSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/HealthChecksSpringProperties.java new file mode 100644 index 0000000000..171d8d333c --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/HealthChecksSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for HealthChecks client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.health-checks") +public class HealthChecksSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImageFamilyViewsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImageFamilyViewsSpringAutoConfiguration.java new file mode 100644 index 0000000000..4981b81ea8 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImageFamilyViewsSpringAutoConfiguration.java @@ -0,0 +1,192 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ImageFamilyViewsClient; +import com.google.cloud.compute.v1.ImageFamilyViewsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ImageFamilyViewsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ImageFamilyViewsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.image-family-views.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(ImageFamilyViewsSpringProperties.class) +public class ImageFamilyViewsSpringAutoConfiguration { + private final ImageFamilyViewsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(ImageFamilyViewsSpringAutoConfiguration.class); + + protected ImageFamilyViewsSpringAutoConfiguration( + ImageFamilyViewsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from ImageFamilyViews-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultImageFamilyViewsTransportChannelProvider") + public TransportChannelProvider defaultImageFamilyViewsTransportChannelProvider() { + return ImageFamilyViewsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ImageFamilyViewsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultImageFamilyViewsTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ImageFamilyViewsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ImageFamilyViewsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public ImageFamilyViewsSettings imageFamilyViewsSettings( + @Qualifier("defaultImageFamilyViewsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ImageFamilyViewsSettings.Builder clientSettingsBuilder = ImageFamilyViewsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ImageFamilyViewsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ImageFamilyViewsClient bean configured with ImageFamilyViewsSettings. + * + * @param imageFamilyViewsSettings settings to configure an instance of client bean. + * @return a {@link ImageFamilyViewsClient} bean configured with {@link ImageFamilyViewsSettings} + */ + @Bean + @ConditionalOnMissingBean + public ImageFamilyViewsClient imageFamilyViewsClient( + ImageFamilyViewsSettings imageFamilyViewsSettings) throws IOException { + return ImageFamilyViewsClient.create(imageFamilyViewsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-image-family-views"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImageFamilyViewsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImageFamilyViewsSpringProperties.java new file mode 100644 index 0000000000..b7f32bb845 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImageFamilyViewsSpringProperties.java @@ -0,0 +1,88 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for ImageFamilyViews client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.image-family-views") +public class ImageFamilyViewsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImagesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImagesSpringAutoConfiguration.java new file mode 100644 index 0000000000..ba13116027 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImagesSpringAutoConfiguration.java @@ -0,0 +1,266 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ImagesClient; +import com.google.cloud.compute.v1.ImagesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ImagesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ImagesClient.class) +@ConditionalOnProperty(value = "com.google.cloud.compute.v1.images.enabled", matchIfMissing = true) +@EnableConfigurationProperties(ImagesSpringProperties.class) +public class ImagesSpringAutoConfiguration { + private final ImagesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(ImagesSpringAutoConfiguration.class); + + protected ImagesSpringAutoConfiguration( + ImagesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Images-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultImagesTransportChannelProvider") + public TransportChannelProvider defaultImagesTransportChannelProvider() { + return ImagesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ImagesSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultImagesTransportChannelProvider()). It also + * configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ImagesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ImagesSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public ImagesSettings imagesSettings( + @Qualifier("defaultImagesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ImagesSettings.Builder clientSettingsBuilder = ImagesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ImagesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getFromFamilyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getFromFamilySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getFromFamilySettings().setRetrySettings(getFromFamilyRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getFromFamilyRetry = clientProperties.getGetFromFamilyRetry(); + if (getFromFamilyRetry != null) { + RetrySettings getFromFamilyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getFromFamilySettings().getRetrySettings(), getFromFamilyRetry); + clientSettingsBuilder.getFromFamilySettings().setRetrySettings(getFromFamilyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getFromFamily from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ImagesClient bean configured with ImagesSettings. + * + * @param imagesSettings settings to configure an instance of client bean. + * @return a {@link ImagesClient} bean configured with {@link ImagesSettings} + */ + @Bean + @ConditionalOnMissingBean + public ImagesClient imagesClient(ImagesSettings imagesSettings) throws IOException { + return ImagesClient.create(imagesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-images"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImagesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImagesSpringProperties.java new file mode 100644 index 0000000000..c22f207d99 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ImagesSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Images client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.images") +public class ImagesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getFromFamily. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getFromFamilyRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetFromFamilyRetry() { + return this.getFromFamilyRetry; + } + + public void setGetFromFamilyRetry(Retry getFromFamilyRetry) { + this.getFromFamilyRetry = getFromFamilyRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupManagersSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupManagersSpringAutoConfiguration.java new file mode 100644 index 0000000000..02c614ec72 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupManagersSpringAutoConfiguration.java @@ -0,0 +1,285 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.InstanceGroupManagersClient; +import com.google.cloud.compute.v1.InstanceGroupManagersSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link InstanceGroupManagersClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(InstanceGroupManagersClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.instance-group-managers.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(InstanceGroupManagersSpringProperties.class) +public class InstanceGroupManagersSpringAutoConfiguration { + private final InstanceGroupManagersSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(InstanceGroupManagersSpringAutoConfiguration.class); + + protected InstanceGroupManagersSpringAutoConfiguration( + InstanceGroupManagersSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from InstanceGroupManagers-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultInstanceGroupManagersTransportChannelProvider") + public TransportChannelProvider defaultInstanceGroupManagersTransportChannelProvider() { + return InstanceGroupManagersSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a InstanceGroupManagersSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultInstanceGroupManagersTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in InstanceGroupManagersSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link InstanceGroupManagersSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public InstanceGroupManagersSettings instanceGroupManagersSettings( + @Qualifier("defaultInstanceGroupManagersTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + InstanceGroupManagersSettings.Builder clientSettingsBuilder = + InstanceGroupManagersSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + InstanceGroupManagersSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listErrorsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listErrorsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listErrorsSettings().setRetrySettings(listErrorsRetrySettings); + + RetrySettings listManagedInstancesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listManagedInstancesSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listManagedInstancesSettings() + .setRetrySettings(listManagedInstancesRetrySettings); + + RetrySettings listPerInstanceConfigsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listPerInstanceConfigsSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listPerInstanceConfigsSettings() + .setRetrySettings(listPerInstanceConfigsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listErrorsRetry = clientProperties.getListErrorsRetry(); + if (listErrorsRetry != null) { + RetrySettings listErrorsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listErrorsSettings().getRetrySettings(), listErrorsRetry); + clientSettingsBuilder.listErrorsSettings().setRetrySettings(listErrorsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for listErrors from properties."); + } + } + Retry listManagedInstancesRetry = clientProperties.getListManagedInstancesRetry(); + if (listManagedInstancesRetry != null) { + RetrySettings listManagedInstancesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listManagedInstancesSettings().getRetrySettings(), + listManagedInstancesRetry); + clientSettingsBuilder + .listManagedInstancesSettings() + .setRetrySettings(listManagedInstancesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listManagedInstances from properties."); + } + } + Retry listPerInstanceConfigsRetry = clientProperties.getListPerInstanceConfigsRetry(); + if (listPerInstanceConfigsRetry != null) { + RetrySettings listPerInstanceConfigsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listPerInstanceConfigsSettings().getRetrySettings(), + listPerInstanceConfigsRetry); + clientSettingsBuilder + .listPerInstanceConfigsSettings() + .setRetrySettings(listPerInstanceConfigsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listPerInstanceConfigs from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a InstanceGroupManagersClient bean configured with InstanceGroupManagersSettings. + * + * @param instanceGroupManagersSettings settings to configure an instance of client bean. + * @return a {@link InstanceGroupManagersClient} bean configured with {@link + * InstanceGroupManagersSettings} + */ + @Bean + @ConditionalOnMissingBean + public InstanceGroupManagersClient instanceGroupManagersClient( + InstanceGroupManagersSettings instanceGroupManagersSettings) throws IOException { + return InstanceGroupManagersClient.create(instanceGroupManagersSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-instance-group-managers"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupManagersSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupManagersSpringProperties.java new file mode 100644 index 0000000000..a5b1a4d31e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupManagersSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for InstanceGroupManagers client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.instance-group-managers") +public class InstanceGroupManagersSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listErrors. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listErrorsRetry; + /** + * Allow override of retry settings at method-level for listManagedInstances. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listManagedInstancesRetry; + /** + * Allow override of retry settings at method-level for listPerInstanceConfigs. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listPerInstanceConfigsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListErrorsRetry() { + return this.listErrorsRetry; + } + + public void setListErrorsRetry(Retry listErrorsRetry) { + this.listErrorsRetry = listErrorsRetry; + } + + public Retry getListManagedInstancesRetry() { + return this.listManagedInstancesRetry; + } + + public void setListManagedInstancesRetry(Retry listManagedInstancesRetry) { + this.listManagedInstancesRetry = listManagedInstancesRetry; + } + + public Retry getListPerInstanceConfigsRetry() { + return this.listPerInstanceConfigsRetry; + } + + public void setListPerInstanceConfigsRetry(Retry listPerInstanceConfigsRetry) { + this.listPerInstanceConfigsRetry = listPerInstanceConfigsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupsSpringAutoConfiguration.java new file mode 100644 index 0000000000..d1abe68f03 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupsSpringAutoConfiguration.java @@ -0,0 +1,237 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.InstanceGroupsClient; +import com.google.cloud.compute.v1.InstanceGroupsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link InstanceGroupsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(InstanceGroupsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.instance-groups.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(InstanceGroupsSpringProperties.class) +public class InstanceGroupsSpringAutoConfiguration { + private final InstanceGroupsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(InstanceGroupsSpringAutoConfiguration.class); + + protected InstanceGroupsSpringAutoConfiguration( + InstanceGroupsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from InstanceGroups-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultInstanceGroupsTransportChannelProvider") + public TransportChannelProvider defaultInstanceGroupsTransportChannelProvider() { + return InstanceGroupsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a InstanceGroupsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultInstanceGroupsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in InstanceGroupsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link InstanceGroupsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public InstanceGroupsSettings instanceGroupsSettings( + @Qualifier("defaultInstanceGroupsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + InstanceGroupsSettings.Builder clientSettingsBuilder = InstanceGroupsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + InstanceGroupsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listInstancesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listInstancesSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listInstancesSettings().setRetrySettings(listInstancesRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listInstancesRetry = clientProperties.getListInstancesRetry(); + if (listInstancesRetry != null) { + RetrySettings listInstancesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listInstancesSettings().getRetrySettings(), listInstancesRetry); + clientSettingsBuilder.listInstancesSettings().setRetrySettings(listInstancesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for listInstances from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a InstanceGroupsClient bean configured with InstanceGroupsSettings. + * + * @param instanceGroupsSettings settings to configure an instance of client bean. + * @return a {@link InstanceGroupsClient} bean configured with {@link InstanceGroupsSettings} + */ + @Bean + @ConditionalOnMissingBean + public InstanceGroupsClient instanceGroupsClient(InstanceGroupsSettings instanceGroupsSettings) + throws IOException { + return InstanceGroupsClient.create(instanceGroupsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-instance-groups"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupsSpringProperties.java new file mode 100644 index 0000000000..9e034ec166 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceGroupsSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for InstanceGroups client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.instance-groups") +public class InstanceGroupsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listInstances. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listInstancesRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListInstancesRetry() { + return this.listInstancesRetry; + } + + public void setListInstancesRetry(Retry listInstancesRetry) { + this.listInstancesRetry = listInstancesRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceTemplatesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceTemplatesSpringAutoConfiguration.java new file mode 100644 index 0000000000..e45feafd5d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceTemplatesSpringAutoConfiguration.java @@ -0,0 +1,276 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.InstanceTemplatesClient; +import com.google.cloud.compute.v1.InstanceTemplatesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link InstanceTemplatesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(InstanceTemplatesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.instance-templates.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(InstanceTemplatesSpringProperties.class) +public class InstanceTemplatesSpringAutoConfiguration { + private final InstanceTemplatesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(InstanceTemplatesSpringAutoConfiguration.class); + + protected InstanceTemplatesSpringAutoConfiguration( + InstanceTemplatesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from InstanceTemplates-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultInstanceTemplatesTransportChannelProvider") + public TransportChannelProvider defaultInstanceTemplatesTransportChannelProvider() { + return InstanceTemplatesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a InstanceTemplatesSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultInstanceTemplatesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in InstanceTemplatesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link InstanceTemplatesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public InstanceTemplatesSettings instanceTemplatesSettings( + @Qualifier("defaultInstanceTemplatesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + InstanceTemplatesSettings.Builder clientSettingsBuilder = + InstanceTemplatesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + InstanceTemplatesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a InstanceTemplatesClient bean configured with InstanceTemplatesSettings. + * + * @param instanceTemplatesSettings settings to configure an instance of client bean. + * @return a {@link InstanceTemplatesClient} bean configured with {@link + * InstanceTemplatesSettings} + */ + @Bean + @ConditionalOnMissingBean + public InstanceTemplatesClient instanceTemplatesClient( + InstanceTemplatesSettings instanceTemplatesSettings) throws IOException { + return InstanceTemplatesClient.create(instanceTemplatesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-instance-templates"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceTemplatesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceTemplatesSpringProperties.java new file mode 100644 index 0000000000..7a1b00c72a --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstanceTemplatesSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for InstanceTemplates client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.instance-templates") +public class InstanceTemplatesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstancesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstancesSpringAutoConfiguration.java new file mode 100644 index 0000000000..e5dc99034e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstancesSpringAutoConfiguration.java @@ -0,0 +1,407 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.InstancesClient; +import com.google.cloud.compute.v1.InstancesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link InstancesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(InstancesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.instances.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(InstancesSpringProperties.class) +public class InstancesSpringAutoConfiguration { + private final InstancesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(InstancesSpringAutoConfiguration.class); + + protected InstancesSpringAutoConfiguration( + InstancesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Instances-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultInstancesTransportChannelProvider") + public TransportChannelProvider defaultInstancesTransportChannelProvider() { + return InstancesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a InstancesSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultInstancesTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in InstancesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link InstancesSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public InstancesSettings instancesSettings( + @Qualifier("defaultInstancesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + InstancesSettings.Builder clientSettingsBuilder = InstancesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + InstancesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getEffectiveFirewallsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getEffectiveFirewallsSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .getEffectiveFirewallsSettings() + .setRetrySettings(getEffectiveFirewallsRetrySettings); + + RetrySettings getGuestAttributesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getGuestAttributesSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .getGuestAttributesSettings() + .setRetrySettings(getGuestAttributesRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings getScreenshotRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getScreenshotSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getScreenshotSettings().setRetrySettings(getScreenshotRetrySettings); + + RetrySettings getSerialPortOutputRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSerialPortOutputSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .getSerialPortOutputSettings() + .setRetrySettings(getSerialPortOutputRetrySettings); + + RetrySettings getShieldedInstanceIdentityRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getShieldedInstanceIdentitySettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .getShieldedInstanceIdentitySettings() + .setRetrySettings(getShieldedInstanceIdentityRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listReferrersRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listReferrersSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listReferrersSettings().setRetrySettings(listReferrersRetrySettings); + + RetrySettings sendDiagnosticInterruptRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.sendDiagnosticInterruptSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .sendDiagnosticInterruptSettings() + .setRetrySettings(sendDiagnosticInterruptRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getEffectiveFirewallsRetry = clientProperties.getGetEffectiveFirewallsRetry(); + if (getEffectiveFirewallsRetry != null) { + RetrySettings getEffectiveFirewallsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getEffectiveFirewallsSettings().getRetrySettings(), + getEffectiveFirewallsRetry); + clientSettingsBuilder + .getEffectiveFirewallsSettings() + .setRetrySettings(getEffectiveFirewallsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for getEffectiveFirewalls from properties."); + } + } + Retry getGuestAttributesRetry = clientProperties.getGetGuestAttributesRetry(); + if (getGuestAttributesRetry != null) { + RetrySettings getGuestAttributesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getGuestAttributesSettings().getRetrySettings(), + getGuestAttributesRetry); + clientSettingsBuilder + .getGuestAttributesSettings() + .setRetrySettings(getGuestAttributesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for getGuestAttributes from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry getScreenshotRetry = clientProperties.getGetScreenshotRetry(); + if (getScreenshotRetry != null) { + RetrySettings getScreenshotRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getScreenshotSettings().getRetrySettings(), getScreenshotRetry); + clientSettingsBuilder.getScreenshotSettings().setRetrySettings(getScreenshotRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getScreenshot from properties."); + } + } + Retry getSerialPortOutputRetry = clientProperties.getGetSerialPortOutputRetry(); + if (getSerialPortOutputRetry != null) { + RetrySettings getSerialPortOutputRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSerialPortOutputSettings().getRetrySettings(), + getSerialPortOutputRetry); + clientSettingsBuilder + .getSerialPortOutputSettings() + .setRetrySettings(getSerialPortOutputRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for getSerialPortOutput from properties."); + } + } + Retry getShieldedInstanceIdentityRetry = clientProperties.getGetShieldedInstanceIdentityRetry(); + if (getShieldedInstanceIdentityRetry != null) { + RetrySettings getShieldedInstanceIdentityRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getShieldedInstanceIdentitySettings().getRetrySettings(), + getShieldedInstanceIdentityRetry); + clientSettingsBuilder + .getShieldedInstanceIdentitySettings() + .setRetrySettings(getShieldedInstanceIdentityRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for getShieldedInstanceIdentity from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listReferrersRetry = clientProperties.getListReferrersRetry(); + if (listReferrersRetry != null) { + RetrySettings listReferrersRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listReferrersSettings().getRetrySettings(), listReferrersRetry); + clientSettingsBuilder.listReferrersSettings().setRetrySettings(listReferrersRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for listReferrers from properties."); + } + } + Retry sendDiagnosticInterruptRetry = clientProperties.getSendDiagnosticInterruptRetry(); + if (sendDiagnosticInterruptRetry != null) { + RetrySettings sendDiagnosticInterruptRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.sendDiagnosticInterruptSettings().getRetrySettings(), + sendDiagnosticInterruptRetry); + clientSettingsBuilder + .sendDiagnosticInterruptSettings() + .setRetrySettings(sendDiagnosticInterruptRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for sendDiagnosticInterrupt from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a InstancesClient bean configured with InstancesSettings. + * + * @param instancesSettings settings to configure an instance of client bean. + * @return a {@link InstancesClient} bean configured with {@link InstancesSettings} + */ + @Bean + @ConditionalOnMissingBean + public InstancesClient instancesClient(InstancesSettings instancesSettings) throws IOException { + return InstancesClient.create(instancesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-instances"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstancesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstancesSpringProperties.java new file mode 100644 index 0000000000..a68cd51c98 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InstancesSpringProperties.java @@ -0,0 +1,243 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Instances client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.instances") +public class InstancesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getEffectiveFirewalls. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getEffectiveFirewallsRetry; + /** + * Allow override of retry settings at method-level for getGuestAttributes. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getGuestAttributesRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for getScreenshot. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getScreenshotRetry; + /** + * Allow override of retry settings at method-level for getSerialPortOutput. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getSerialPortOutputRetry; + /** + * Allow override of retry settings at method-level for getShieldedInstanceIdentity. If defined, + * this takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getShieldedInstanceIdentityRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listReferrers. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listReferrersRetry; + /** + * Allow override of retry settings at method-level for sendDiagnosticInterrupt. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry sendDiagnosticInterruptRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetEffectiveFirewallsRetry() { + return this.getEffectiveFirewallsRetry; + } + + public void setGetEffectiveFirewallsRetry(Retry getEffectiveFirewallsRetry) { + this.getEffectiveFirewallsRetry = getEffectiveFirewallsRetry; + } + + public Retry getGetGuestAttributesRetry() { + return this.getGuestAttributesRetry; + } + + public void setGetGuestAttributesRetry(Retry getGuestAttributesRetry) { + this.getGuestAttributesRetry = getGuestAttributesRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getGetScreenshotRetry() { + return this.getScreenshotRetry; + } + + public void setGetScreenshotRetry(Retry getScreenshotRetry) { + this.getScreenshotRetry = getScreenshotRetry; + } + + public Retry getGetSerialPortOutputRetry() { + return this.getSerialPortOutputRetry; + } + + public void setGetSerialPortOutputRetry(Retry getSerialPortOutputRetry) { + this.getSerialPortOutputRetry = getSerialPortOutputRetry; + } + + public Retry getGetShieldedInstanceIdentityRetry() { + return this.getShieldedInstanceIdentityRetry; + } + + public void setGetShieldedInstanceIdentityRetry(Retry getShieldedInstanceIdentityRetry) { + this.getShieldedInstanceIdentityRetry = getShieldedInstanceIdentityRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListReferrersRetry() { + return this.listReferrersRetry; + } + + public void setListReferrersRetry(Retry listReferrersRetry) { + this.listReferrersRetry = listReferrersRetry; + } + + public Retry getSendDiagnosticInterruptRetry() { + return this.sendDiagnosticInterruptRetry; + } + + public void setSendDiagnosticInterruptRetry(Retry sendDiagnosticInterruptRetry) { + this.sendDiagnosticInterruptRetry = sendDiagnosticInterruptRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectAttachmentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectAttachmentsSpringAutoConfiguration.java new file mode 100644 index 0000000000..9cb212bdce --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectAttachmentsSpringAutoConfiguration.java @@ -0,0 +1,226 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.InterconnectAttachmentsClient; +import com.google.cloud.compute.v1.InterconnectAttachmentsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link InterconnectAttachmentsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(InterconnectAttachmentsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.interconnect-attachments.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(InterconnectAttachmentsSpringProperties.class) +public class InterconnectAttachmentsSpringAutoConfiguration { + private final InterconnectAttachmentsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(InterconnectAttachmentsSpringAutoConfiguration.class); + + protected InterconnectAttachmentsSpringAutoConfiguration( + InterconnectAttachmentsSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from InterconnectAttachments-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultInterconnectAttachmentsTransportChannelProvider") + public TransportChannelProvider defaultInterconnectAttachmentsTransportChannelProvider() { + return InterconnectAttachmentsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a InterconnectAttachmentsSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultInterconnectAttachmentsTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in InterconnectAttachmentsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link InterconnectAttachmentsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public InterconnectAttachmentsSettings interconnectAttachmentsSettings( + @Qualifier("defaultInterconnectAttachmentsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + InterconnectAttachmentsSettings.Builder clientSettingsBuilder = + InterconnectAttachmentsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + InterconnectAttachmentsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a InterconnectAttachmentsClient bean configured with InterconnectAttachmentsSettings. + * + * @param interconnectAttachmentsSettings settings to configure an instance of client bean. + * @return a {@link InterconnectAttachmentsClient} bean configured with {@link + * InterconnectAttachmentsSettings} + */ + @Bean + @ConditionalOnMissingBean + public InterconnectAttachmentsClient interconnectAttachmentsClient( + InterconnectAttachmentsSettings interconnectAttachmentsSettings) throws IOException { + return InterconnectAttachmentsClient.create(interconnectAttachmentsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-interconnect-attachments"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectAttachmentsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectAttachmentsSpringProperties.java new file mode 100644 index 0000000000..0c433b6705 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectAttachmentsSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for InterconnectAttachments client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.interconnect-attachments") +public class InterconnectAttachmentsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectLocationsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectLocationsSpringAutoConfiguration.java new file mode 100644 index 0000000000..5a03bde56f --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectLocationsSpringAutoConfiguration.java @@ -0,0 +1,210 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.InterconnectLocationsClient; +import com.google.cloud.compute.v1.InterconnectLocationsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link InterconnectLocationsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(InterconnectLocationsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.interconnect-locations.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(InterconnectLocationsSpringProperties.class) +public class InterconnectLocationsSpringAutoConfiguration { + private final InterconnectLocationsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(InterconnectLocationsSpringAutoConfiguration.class); + + protected InterconnectLocationsSpringAutoConfiguration( + InterconnectLocationsSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from InterconnectLocations-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultInterconnectLocationsTransportChannelProvider") + public TransportChannelProvider defaultInterconnectLocationsTransportChannelProvider() { + return InterconnectLocationsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a InterconnectLocationsSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultInterconnectLocationsTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in InterconnectLocationsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link InterconnectLocationsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public InterconnectLocationsSettings interconnectLocationsSettings( + @Qualifier("defaultInterconnectLocationsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + InterconnectLocationsSettings.Builder clientSettingsBuilder = + InterconnectLocationsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + InterconnectLocationsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a InterconnectLocationsClient bean configured with InterconnectLocationsSettings. + * + * @param interconnectLocationsSettings settings to configure an instance of client bean. + * @return a {@link InterconnectLocationsClient} bean configured with {@link + * InterconnectLocationsSettings} + */ + @Bean + @ConditionalOnMissingBean + public InterconnectLocationsClient interconnectLocationsClient( + InterconnectLocationsSettings interconnectLocationsSettings) throws IOException { + return InterconnectLocationsClient.create(interconnectLocationsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-interconnect-locations"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectLocationsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectLocationsSpringProperties.java new file mode 100644 index 0000000000..796cf9d10d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectLocationsSpringProperties.java @@ -0,0 +1,101 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for InterconnectLocations client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.interconnect-locations") +public class InterconnectLocationsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectsSpringAutoConfiguration.java new file mode 100644 index 0000000000..d5c5fb6f8d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectsSpringAutoConfiguration.java @@ -0,0 +1,222 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.InterconnectsClient; +import com.google.cloud.compute.v1.InterconnectsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link InterconnectsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(InterconnectsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.interconnects.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(InterconnectsSpringProperties.class) +public class InterconnectsSpringAutoConfiguration { + private final InterconnectsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(InterconnectsSpringAutoConfiguration.class); + + protected InterconnectsSpringAutoConfiguration( + InterconnectsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Interconnects-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultInterconnectsTransportChannelProvider") + public TransportChannelProvider defaultInterconnectsTransportChannelProvider() { + return InterconnectsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a InterconnectsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultInterconnectsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in InterconnectsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link InterconnectsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public InterconnectsSettings interconnectsSettings( + @Qualifier("defaultInterconnectsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + InterconnectsSettings.Builder clientSettingsBuilder = InterconnectsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + InterconnectsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getDiagnosticsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getDiagnosticsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getDiagnosticsSettings().setRetrySettings(getDiagnosticsRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getDiagnosticsRetry = clientProperties.getGetDiagnosticsRetry(); + if (getDiagnosticsRetry != null) { + RetrySettings getDiagnosticsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getDiagnosticsSettings().getRetrySettings(), + getDiagnosticsRetry); + clientSettingsBuilder.getDiagnosticsSettings().setRetrySettings(getDiagnosticsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getDiagnostics from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a InterconnectsClient bean configured with InterconnectsSettings. + * + * @param interconnectsSettings settings to configure an instance of client bean. + * @return a {@link InterconnectsClient} bean configured with {@link InterconnectsSettings} + */ + @Bean + @ConditionalOnMissingBean + public InterconnectsClient interconnectsClient(InterconnectsSettings interconnectsSettings) + throws IOException { + return InterconnectsClient.create(interconnectsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-interconnects"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectsSpringProperties.java new file mode 100644 index 0000000000..0afefb3d58 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/InterconnectsSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Interconnects client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.interconnects") +public class InterconnectsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getDiagnostics. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getDiagnosticsRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetDiagnosticsRetry() { + return this.getDiagnosticsRetry; + } + + public void setGetDiagnosticsRetry(Retry getDiagnosticsRetry) { + this.getDiagnosticsRetry = getDiagnosticsRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicenseCodesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicenseCodesSpringAutoConfiguration.java new file mode 100644 index 0000000000..79b4784316 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicenseCodesSpringAutoConfiguration.java @@ -0,0 +1,212 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.LicenseCodesClient; +import com.google.cloud.compute.v1.LicenseCodesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link LicenseCodesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(LicenseCodesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.license-codes.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(LicenseCodesSpringProperties.class) +public class LicenseCodesSpringAutoConfiguration { + private final LicenseCodesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(LicenseCodesSpringAutoConfiguration.class); + + protected LicenseCodesSpringAutoConfiguration( + LicenseCodesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from LicenseCodes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultLicenseCodesTransportChannelProvider") + public TransportChannelProvider defaultLicenseCodesTransportChannelProvider() { + return LicenseCodesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a LicenseCodesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultLicenseCodesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in LicenseCodesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link LicenseCodesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public LicenseCodesSettings licenseCodesSettings( + @Qualifier("defaultLicenseCodesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + LicenseCodesSettings.Builder clientSettingsBuilder = LicenseCodesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + LicenseCodesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a LicenseCodesClient bean configured with LicenseCodesSettings. + * + * @param licenseCodesSettings settings to configure an instance of client bean. + * @return a {@link LicenseCodesClient} bean configured with {@link LicenseCodesSettings} + */ + @Bean + @ConditionalOnMissingBean + public LicenseCodesClient licenseCodesClient(LicenseCodesSettings licenseCodesSettings) + throws IOException { + return LicenseCodesClient.create(licenseCodesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-license-codes"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicenseCodesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicenseCodesSpringProperties.java new file mode 100644 index 0000000000..0e3e72f257 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicenseCodesSpringProperties.java @@ -0,0 +1,101 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for LicenseCodes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.license-codes") +public class LicenseCodesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicensesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicensesSpringAutoConfiguration.java new file mode 100644 index 0000000000..5a4c776d43 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicensesSpringAutoConfiguration.java @@ -0,0 +1,253 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.LicensesClient; +import com.google.cloud.compute.v1.LicensesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link LicensesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(LicensesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.licenses.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(LicensesSpringProperties.class) +public class LicensesSpringAutoConfiguration { + private final LicensesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(LicensesSpringAutoConfiguration.class); + + protected LicensesSpringAutoConfiguration( + LicensesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Licenses-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultLicensesTransportChannelProvider") + public TransportChannelProvider defaultLicensesTransportChannelProvider() { + return LicensesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a LicensesSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultLicensesTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in LicensesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link LicensesSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public LicensesSettings licensesSettings( + @Qualifier("defaultLicensesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + LicensesSettings.Builder clientSettingsBuilder = LicensesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + LicensesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a LicensesClient bean configured with LicensesSettings. + * + * @param licensesSettings settings to configure an instance of client bean. + * @return a {@link LicensesClient} bean configured with {@link LicensesSettings} + */ + @Bean + @ConditionalOnMissingBean + public LicensesClient licensesClient(LicensesSettings licensesSettings) throws IOException { + return LicensesClient.create(licensesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-licenses"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicensesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicensesSpringProperties.java new file mode 100644 index 0000000000..d615d58e5e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/LicensesSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Licenses client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.licenses") +public class LicensesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineImagesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineImagesSpringAutoConfiguration.java new file mode 100644 index 0000000000..1789b4d01f --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineImagesSpringAutoConfiguration.java @@ -0,0 +1,257 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.MachineImagesClient; +import com.google.cloud.compute.v1.MachineImagesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link MachineImagesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(MachineImagesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.machine-images.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(MachineImagesSpringProperties.class) +public class MachineImagesSpringAutoConfiguration { + private final MachineImagesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(MachineImagesSpringAutoConfiguration.class); + + protected MachineImagesSpringAutoConfiguration( + MachineImagesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from MachineImages-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultMachineImagesTransportChannelProvider") + public TransportChannelProvider defaultMachineImagesTransportChannelProvider() { + return MachineImagesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a MachineImagesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultMachineImagesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in MachineImagesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link MachineImagesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public MachineImagesSettings machineImagesSettings( + @Qualifier("defaultMachineImagesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + MachineImagesSettings.Builder clientSettingsBuilder = MachineImagesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + MachineImagesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a MachineImagesClient bean configured with MachineImagesSettings. + * + * @param machineImagesSettings settings to configure an instance of client bean. + * @return a {@link MachineImagesClient} bean configured with {@link MachineImagesSettings} + */ + @Bean + @ConditionalOnMissingBean + public MachineImagesClient machineImagesClient(MachineImagesSettings machineImagesSettings) + throws IOException { + return MachineImagesClient.create(machineImagesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-machine-images"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineImagesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineImagesSpringProperties.java new file mode 100644 index 0000000000..002142b77e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineImagesSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for MachineImages client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.machine-images") +public class MachineImagesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineTypesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineTypesSpringAutoConfiguration.java new file mode 100644 index 0000000000..82d1df4898 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineTypesSpringAutoConfiguration.java @@ -0,0 +1,222 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.MachineTypesClient; +import com.google.cloud.compute.v1.MachineTypesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link MachineTypesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(MachineTypesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.machine-types.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(MachineTypesSpringProperties.class) +public class MachineTypesSpringAutoConfiguration { + private final MachineTypesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(MachineTypesSpringAutoConfiguration.class); + + protected MachineTypesSpringAutoConfiguration( + MachineTypesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from MachineTypes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultMachineTypesTransportChannelProvider") + public TransportChannelProvider defaultMachineTypesTransportChannelProvider() { + return MachineTypesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a MachineTypesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultMachineTypesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in MachineTypesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link MachineTypesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public MachineTypesSettings machineTypesSettings( + @Qualifier("defaultMachineTypesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + MachineTypesSettings.Builder clientSettingsBuilder = MachineTypesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + MachineTypesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a MachineTypesClient bean configured with MachineTypesSettings. + * + * @param machineTypesSettings settings to configure an instance of client bean. + * @return a {@link MachineTypesClient} bean configured with {@link MachineTypesSettings} + */ + @Bean + @ConditionalOnMissingBean + public MachineTypesClient machineTypesClient(MachineTypesSettings machineTypesSettings) + throws IOException { + return MachineTypesClient.create(machineTypesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-machine-types"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineTypesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineTypesSpringProperties.java new file mode 100644 index 0000000000..60787a6162 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/MachineTypesSpringProperties.java @@ -0,0 +1,114 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for MachineTypes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.machine-types") +public class MachineTypesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkAttachmentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkAttachmentsSpringAutoConfiguration.java new file mode 100644 index 0000000000..7fb4f12eac --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkAttachmentsSpringAutoConfiguration.java @@ -0,0 +1,276 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.NetworkAttachmentsClient; +import com.google.cloud.compute.v1.NetworkAttachmentsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link NetworkAttachmentsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(NetworkAttachmentsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.network-attachments.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(NetworkAttachmentsSpringProperties.class) +public class NetworkAttachmentsSpringAutoConfiguration { + private final NetworkAttachmentsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(NetworkAttachmentsSpringAutoConfiguration.class); + + protected NetworkAttachmentsSpringAutoConfiguration( + NetworkAttachmentsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from NetworkAttachments-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultNetworkAttachmentsTransportChannelProvider") + public TransportChannelProvider defaultNetworkAttachmentsTransportChannelProvider() { + return NetworkAttachmentsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a NetworkAttachmentsSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultNetworkAttachmentsTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in NetworkAttachmentsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link NetworkAttachmentsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public NetworkAttachmentsSettings networkAttachmentsSettings( + @Qualifier("defaultNetworkAttachmentsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + NetworkAttachmentsSettings.Builder clientSettingsBuilder = + NetworkAttachmentsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + NetworkAttachmentsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a NetworkAttachmentsClient bean configured with NetworkAttachmentsSettings. + * + * @param networkAttachmentsSettings settings to configure an instance of client bean. + * @return a {@link NetworkAttachmentsClient} bean configured with {@link + * NetworkAttachmentsSettings} + */ + @Bean + @ConditionalOnMissingBean + public NetworkAttachmentsClient networkAttachmentsClient( + NetworkAttachmentsSettings networkAttachmentsSettings) throws IOException { + return NetworkAttachmentsClient.create(networkAttachmentsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-network-attachments"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkAttachmentsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkAttachmentsSpringProperties.java new file mode 100644 index 0000000000..396ef7a7ba --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkAttachmentsSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for NetworkAttachments client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.network-attachments") +public class NetworkAttachmentsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEdgeSecurityServicesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEdgeSecurityServicesSpringAutoConfiguration.java new file mode 100644 index 0000000000..0a8bf18b60 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEdgeSecurityServicesSpringAutoConfiguration.java @@ -0,0 +1,212 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.NetworkEdgeSecurityServicesClient; +import com.google.cloud.compute.v1.NetworkEdgeSecurityServicesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link NetworkEdgeSecurityServicesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(NetworkEdgeSecurityServicesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.network-edge-security-services.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(NetworkEdgeSecurityServicesSpringProperties.class) +public class NetworkEdgeSecurityServicesSpringAutoConfiguration { + private final NetworkEdgeSecurityServicesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(NetworkEdgeSecurityServicesSpringAutoConfiguration.class); + + protected NetworkEdgeSecurityServicesSpringAutoConfiguration( + NetworkEdgeSecurityServicesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from NetworkEdgeSecurityServices-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultNetworkEdgeSecurityServicesTransportChannelProvider") + public TransportChannelProvider defaultNetworkEdgeSecurityServicesTransportChannelProvider() { + return NetworkEdgeSecurityServicesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a NetworkEdgeSecurityServicesSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultNetworkEdgeSecurityServicesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in NetworkEdgeSecurityServicesSpringProperties. Method-level properties will take precedence + * over service-level properties if available, and client library defaults will be used if neither + * are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link NetworkEdgeSecurityServicesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public NetworkEdgeSecurityServicesSettings networkEdgeSecurityServicesSettings( + @Qualifier("defaultNetworkEdgeSecurityServicesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + NetworkEdgeSecurityServicesSettings.Builder clientSettingsBuilder = + NetworkEdgeSecurityServicesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + NetworkEdgeSecurityServicesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a NetworkEdgeSecurityServicesClient bean configured with + * NetworkEdgeSecurityServicesSettings. + * + * @param networkEdgeSecurityServicesSettings settings to configure an instance of client bean. + * @return a {@link NetworkEdgeSecurityServicesClient} bean configured with {@link + * NetworkEdgeSecurityServicesSettings} + */ + @Bean + @ConditionalOnMissingBean + public NetworkEdgeSecurityServicesClient networkEdgeSecurityServicesClient( + NetworkEdgeSecurityServicesSettings networkEdgeSecurityServicesSettings) throws IOException { + return NetworkEdgeSecurityServicesClient.create(networkEdgeSecurityServicesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-network-edge-security-services"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEdgeSecurityServicesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEdgeSecurityServicesSpringProperties.java new file mode 100644 index 0000000000..8d0308b0ba --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEdgeSecurityServicesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for NetworkEdgeSecurityServices client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.network-edge-security-services") +public class NetworkEdgeSecurityServicesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEndpointGroupsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEndpointGroupsSpringAutoConfiguration.java new file mode 100644 index 0000000000..8cbfb57dd0 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEndpointGroupsSpringAutoConfiguration.java @@ -0,0 +1,269 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.NetworkEndpointGroupsClient; +import com.google.cloud.compute.v1.NetworkEndpointGroupsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link NetworkEndpointGroupsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(NetworkEndpointGroupsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.network-endpoint-groups.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(NetworkEndpointGroupsSpringProperties.class) +public class NetworkEndpointGroupsSpringAutoConfiguration { + private final NetworkEndpointGroupsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(NetworkEndpointGroupsSpringAutoConfiguration.class); + + protected NetworkEndpointGroupsSpringAutoConfiguration( + NetworkEndpointGroupsSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from NetworkEndpointGroups-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultNetworkEndpointGroupsTransportChannelProvider") + public TransportChannelProvider defaultNetworkEndpointGroupsTransportChannelProvider() { + return NetworkEndpointGroupsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a NetworkEndpointGroupsSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultNetworkEndpointGroupsTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in NetworkEndpointGroupsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link NetworkEndpointGroupsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public NetworkEndpointGroupsSettings networkEndpointGroupsSettings( + @Qualifier("defaultNetworkEndpointGroupsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + NetworkEndpointGroupsSettings.Builder clientSettingsBuilder = + NetworkEndpointGroupsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + NetworkEndpointGroupsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listNetworkEndpointsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listNetworkEndpointsSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listNetworkEndpointsSettings() + .setRetrySettings(listNetworkEndpointsRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listNetworkEndpointsRetry = clientProperties.getListNetworkEndpointsRetry(); + if (listNetworkEndpointsRetry != null) { + RetrySettings listNetworkEndpointsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listNetworkEndpointsSettings().getRetrySettings(), + listNetworkEndpointsRetry); + clientSettingsBuilder + .listNetworkEndpointsSettings() + .setRetrySettings(listNetworkEndpointsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listNetworkEndpoints from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a NetworkEndpointGroupsClient bean configured with NetworkEndpointGroupsSettings. + * + * @param networkEndpointGroupsSettings settings to configure an instance of client bean. + * @return a {@link NetworkEndpointGroupsClient} bean configured with {@link + * NetworkEndpointGroupsSettings} + */ + @Bean + @ConditionalOnMissingBean + public NetworkEndpointGroupsClient networkEndpointGroupsClient( + NetworkEndpointGroupsSettings networkEndpointGroupsSettings) throws IOException { + return NetworkEndpointGroupsClient.create(networkEndpointGroupsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-network-endpoint-groups"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEndpointGroupsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEndpointGroupsSpringProperties.java new file mode 100644 index 0000000000..8dd4684f0e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkEndpointGroupsSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for NetworkEndpointGroups client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.network-endpoint-groups") +public class NetworkEndpointGroupsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listNetworkEndpoints. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listNetworkEndpointsRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListNetworkEndpointsRetry() { + return this.listNetworkEndpointsRetry; + } + + public void setListNetworkEndpointsRetry(Retry listNetworkEndpointsRetry) { + this.listNetworkEndpointsRetry = listNetworkEndpointsRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkFirewallPoliciesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkFirewallPoliciesSpringAutoConfiguration.java new file mode 100644 index 0000000000..ea1fa2ba3b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkFirewallPoliciesSpringAutoConfiguration.java @@ -0,0 +1,292 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.NetworkFirewallPoliciesClient; +import com.google.cloud.compute.v1.NetworkFirewallPoliciesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link NetworkFirewallPoliciesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(NetworkFirewallPoliciesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.network-firewall-policies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(NetworkFirewallPoliciesSpringProperties.class) +public class NetworkFirewallPoliciesSpringAutoConfiguration { + private final NetworkFirewallPoliciesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(NetworkFirewallPoliciesSpringAutoConfiguration.class); + + protected NetworkFirewallPoliciesSpringAutoConfiguration( + NetworkFirewallPoliciesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from NetworkFirewallPolicies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultNetworkFirewallPoliciesTransportChannelProvider") + public TransportChannelProvider defaultNetworkFirewallPoliciesTransportChannelProvider() { + return NetworkFirewallPoliciesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a NetworkFirewallPoliciesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultNetworkFirewallPoliciesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in NetworkFirewallPoliciesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link NetworkFirewallPoliciesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public NetworkFirewallPoliciesSettings networkFirewallPoliciesSettings( + @Qualifier("defaultNetworkFirewallPoliciesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + NetworkFirewallPoliciesSettings.Builder clientSettingsBuilder = + NetworkFirewallPoliciesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + NetworkFirewallPoliciesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getAssociationRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getAssociationSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getAssociationSettings().setRetrySettings(getAssociationRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings getRuleRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRuleSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getRuleSettings().setRetrySettings(getRuleRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getAssociationRetry = clientProperties.getGetAssociationRetry(); + if (getAssociationRetry != null) { + RetrySettings getAssociationRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getAssociationSettings().getRetrySettings(), + getAssociationRetry); + clientSettingsBuilder.getAssociationSettings().setRetrySettings(getAssociationRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getAssociation from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry getRuleRetry = clientProperties.getGetRuleRetry(); + if (getRuleRetry != null) { + RetrySettings getRuleRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRuleSettings().getRetrySettings(), getRuleRetry); + clientSettingsBuilder.getRuleSettings().setRetrySettings(getRuleRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getRule from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a NetworkFirewallPoliciesClient bean configured with NetworkFirewallPoliciesSettings. + * + * @param networkFirewallPoliciesSettings settings to configure an instance of client bean. + * @return a {@link NetworkFirewallPoliciesClient} bean configured with {@link + * NetworkFirewallPoliciesSettings} + */ + @Bean + @ConditionalOnMissingBean + public NetworkFirewallPoliciesClient networkFirewallPoliciesClient( + NetworkFirewallPoliciesSettings networkFirewallPoliciesSettings) throws IOException { + return NetworkFirewallPoliciesClient.create(networkFirewallPoliciesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-network-firewall-policies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkFirewallPoliciesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkFirewallPoliciesSpringProperties.java new file mode 100644 index 0000000000..9dfaff42e2 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworkFirewallPoliciesSpringProperties.java @@ -0,0 +1,165 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for NetworkFirewallPolicies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.network-firewall-policies") +public class NetworkFirewallPoliciesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getAssociation. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getAssociationRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for getRule. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRuleRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetAssociationRetry() { + return this.getAssociationRetry; + } + + public void setGetAssociationRetry(Retry getAssociationRetry) { + this.getAssociationRetry = getAssociationRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getGetRuleRetry() { + return this.getRuleRetry; + } + + public void setGetRuleRetry(Retry getRuleRetry) { + this.getRuleRetry = getRuleRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworksSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworksSpringAutoConfiguration.java new file mode 100644 index 0000000000..c339255bd1 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworksSpringAutoConfiguration.java @@ -0,0 +1,245 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.NetworksClient; +import com.google.cloud.compute.v1.NetworksSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link NetworksClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(NetworksClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.networks.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(NetworksSpringProperties.class) +public class NetworksSpringAutoConfiguration { + private final NetworksSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(NetworksSpringAutoConfiguration.class); + + protected NetworksSpringAutoConfiguration( + NetworksSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Networks-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultNetworksTransportChannelProvider") + public TransportChannelProvider defaultNetworksTransportChannelProvider() { + return NetworksSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a NetworksSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultNetworksTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in NetworksSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link NetworksSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public NetworksSettings networksSettings( + @Qualifier("defaultNetworksTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + NetworksSettings.Builder clientSettingsBuilder = NetworksSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + NetworksSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getEffectiveFirewallsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getEffectiveFirewallsSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .getEffectiveFirewallsSettings() + .setRetrySettings(getEffectiveFirewallsRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listPeeringRoutesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listPeeringRoutesSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .listPeeringRoutesSettings() + .setRetrySettings(listPeeringRoutesRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getEffectiveFirewallsRetry = clientProperties.getGetEffectiveFirewallsRetry(); + if (getEffectiveFirewallsRetry != null) { + RetrySettings getEffectiveFirewallsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getEffectiveFirewallsSettings().getRetrySettings(), + getEffectiveFirewallsRetry); + clientSettingsBuilder + .getEffectiveFirewallsSettings() + .setRetrySettings(getEffectiveFirewallsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for getEffectiveFirewalls from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listPeeringRoutesRetry = clientProperties.getListPeeringRoutesRetry(); + if (listPeeringRoutesRetry != null) { + RetrySettings listPeeringRoutesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listPeeringRoutesSettings().getRetrySettings(), + listPeeringRoutesRetry); + clientSettingsBuilder + .listPeeringRoutesSettings() + .setRetrySettings(listPeeringRoutesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listPeeringRoutes from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a NetworksClient bean configured with NetworksSettings. + * + * @param networksSettings settings to configure an instance of client bean. + * @return a {@link NetworksClient} bean configured with {@link NetworksSettings} + */ + @Bean + @ConditionalOnMissingBean + public NetworksClient networksClient(NetworksSettings networksSettings) throws IOException { + return NetworksClient.create(networksSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-networks"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworksSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworksSpringProperties.java new file mode 100644 index 0000000000..267fc84dee --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NetworksSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Networks client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.networks") +public class NetworksSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getEffectiveFirewalls. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getEffectiveFirewallsRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listPeeringRoutes. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listPeeringRoutesRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetEffectiveFirewallsRetry() { + return this.getEffectiveFirewallsRetry; + } + + public void setGetEffectiveFirewallsRetry(Retry getEffectiveFirewallsRetry) { + this.getEffectiveFirewallsRetry = getEffectiveFirewallsRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListPeeringRoutesRetry() { + return this.listPeeringRoutesRetry; + } + + public void setListPeeringRoutesRetry(Retry listPeeringRoutesRetry) { + this.listPeeringRoutesRetry = listPeeringRoutesRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeGroupsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeGroupsSpringAutoConfiguration.java new file mode 100644 index 0000000000..10e6cd9d2c --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeGroupsSpringAutoConfiguration.java @@ -0,0 +1,287 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.NodeGroupsClient; +import com.google.cloud.compute.v1.NodeGroupsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link NodeGroupsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(NodeGroupsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.node-groups.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(NodeGroupsSpringProperties.class) +public class NodeGroupsSpringAutoConfiguration { + private final NodeGroupsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(NodeGroupsSpringAutoConfiguration.class); + + protected NodeGroupsSpringAutoConfiguration( + NodeGroupsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from NodeGroups-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultNodeGroupsTransportChannelProvider") + public TransportChannelProvider defaultNodeGroupsTransportChannelProvider() { + return NodeGroupsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a NodeGroupsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultNodeGroupsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in NodeGroupsSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link NodeGroupsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public NodeGroupsSettings nodeGroupsSettings( + @Qualifier("defaultNodeGroupsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + NodeGroupsSettings.Builder clientSettingsBuilder = NodeGroupsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + NodeGroupsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listNodesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listNodesSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listNodesSettings().setRetrySettings(listNodesRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listNodesRetry = clientProperties.getListNodesRetry(); + if (listNodesRetry != null) { + RetrySettings listNodesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listNodesSettings().getRetrySettings(), listNodesRetry); + clientSettingsBuilder.listNodesSettings().setRetrySettings(listNodesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for listNodes from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a NodeGroupsClient bean configured with NodeGroupsSettings. + * + * @param nodeGroupsSettings settings to configure an instance of client bean. + * @return a {@link NodeGroupsClient} bean configured with {@link NodeGroupsSettings} + */ + @Bean + @ConditionalOnMissingBean + public NodeGroupsClient nodeGroupsClient(NodeGroupsSettings nodeGroupsSettings) + throws IOException { + return NodeGroupsClient.create(nodeGroupsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-node-groups"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeGroupsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeGroupsSpringProperties.java new file mode 100644 index 0000000000..82f1aaea63 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeGroupsSpringProperties.java @@ -0,0 +1,165 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for NodeGroups client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.node-groups") +public class NodeGroupsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listNodes. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listNodesRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListNodesRetry() { + return this.listNodesRetry; + } + + public void setListNodesRetry(Retry listNodesRetry) { + this.listNodesRetry = listNodesRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTemplatesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTemplatesSpringAutoConfiguration.java new file mode 100644 index 0000000000..fa5eea3072 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTemplatesSpringAutoConfiguration.java @@ -0,0 +1,273 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.NodeTemplatesClient; +import com.google.cloud.compute.v1.NodeTemplatesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link NodeTemplatesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(NodeTemplatesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.node-templates.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(NodeTemplatesSpringProperties.class) +public class NodeTemplatesSpringAutoConfiguration { + private final NodeTemplatesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(NodeTemplatesSpringAutoConfiguration.class); + + protected NodeTemplatesSpringAutoConfiguration( + NodeTemplatesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from NodeTemplates-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultNodeTemplatesTransportChannelProvider") + public TransportChannelProvider defaultNodeTemplatesTransportChannelProvider() { + return NodeTemplatesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a NodeTemplatesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultNodeTemplatesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in NodeTemplatesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link NodeTemplatesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public NodeTemplatesSettings nodeTemplatesSettings( + @Qualifier("defaultNodeTemplatesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + NodeTemplatesSettings.Builder clientSettingsBuilder = NodeTemplatesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + NodeTemplatesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a NodeTemplatesClient bean configured with NodeTemplatesSettings. + * + * @param nodeTemplatesSettings settings to configure an instance of client bean. + * @return a {@link NodeTemplatesClient} bean configured with {@link NodeTemplatesSettings} + */ + @Bean + @ConditionalOnMissingBean + public NodeTemplatesClient nodeTemplatesClient(NodeTemplatesSettings nodeTemplatesSettings) + throws IOException { + return NodeTemplatesClient.create(nodeTemplatesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-node-templates"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTemplatesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTemplatesSpringProperties.java new file mode 100644 index 0000000000..635b832ce4 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTemplatesSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for NodeTemplates client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.node-templates") +public class NodeTemplatesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTypesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTypesSpringAutoConfiguration.java new file mode 100644 index 0000000000..f3e22ba6ba --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTypesSpringAutoConfiguration.java @@ -0,0 +1,218 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.NodeTypesClient; +import com.google.cloud.compute.v1.NodeTypesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link NodeTypesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(NodeTypesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.node-types.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(NodeTypesSpringProperties.class) +public class NodeTypesSpringAutoConfiguration { + private final NodeTypesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(NodeTypesSpringAutoConfiguration.class); + + protected NodeTypesSpringAutoConfiguration( + NodeTypesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from NodeTypes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultNodeTypesTransportChannelProvider") + public TransportChannelProvider defaultNodeTypesTransportChannelProvider() { + return NodeTypesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a NodeTypesSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultNodeTypesTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in NodeTypesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link NodeTypesSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public NodeTypesSettings nodeTypesSettings( + @Qualifier("defaultNodeTypesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + NodeTypesSettings.Builder clientSettingsBuilder = NodeTypesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + NodeTypesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a NodeTypesClient bean configured with NodeTypesSettings. + * + * @param nodeTypesSettings settings to configure an instance of client bean. + * @return a {@link NodeTypesClient} bean configured with {@link NodeTypesSettings} + */ + @Bean + @ConditionalOnMissingBean + public NodeTypesClient nodeTypesClient(NodeTypesSettings nodeTypesSettings) throws IOException { + return NodeTypesClient.create(nodeTypesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-node-types"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTypesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTypesSpringProperties.java new file mode 100644 index 0000000000..d166fc12e3 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/NodeTypesSpringProperties.java @@ -0,0 +1,114 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for NodeTypes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.node-types") +public class NodeTypesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PacketMirroringsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PacketMirroringsSpringAutoConfiguration.java new file mode 100644 index 0000000000..56e5b9e5cd --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PacketMirroringsSpringAutoConfiguration.java @@ -0,0 +1,244 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.PacketMirroringsClient; +import com.google.cloud.compute.v1.PacketMirroringsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link PacketMirroringsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(PacketMirroringsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.packet-mirrorings.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(PacketMirroringsSpringProperties.class) +public class PacketMirroringsSpringAutoConfiguration { + private final PacketMirroringsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(PacketMirroringsSpringAutoConfiguration.class); + + protected PacketMirroringsSpringAutoConfiguration( + PacketMirroringsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from PacketMirrorings-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultPacketMirroringsTransportChannelProvider") + public TransportChannelProvider defaultPacketMirroringsTransportChannelProvider() { + return PacketMirroringsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a PacketMirroringsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultPacketMirroringsTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in PacketMirroringsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link PacketMirroringsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public PacketMirroringsSettings packetMirroringsSettings( + @Qualifier("defaultPacketMirroringsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + PacketMirroringsSettings.Builder clientSettingsBuilder = PacketMirroringsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + PacketMirroringsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a PacketMirroringsClient bean configured with PacketMirroringsSettings. + * + * @param packetMirroringsSettings settings to configure an instance of client bean. + * @return a {@link PacketMirroringsClient} bean configured with {@link PacketMirroringsSettings} + */ + @Bean + @ConditionalOnMissingBean + public PacketMirroringsClient packetMirroringsClient( + PacketMirroringsSettings packetMirroringsSettings) throws IOException { + return PacketMirroringsClient.create(packetMirroringsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-packet-mirrorings"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PacketMirroringsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PacketMirroringsSpringProperties.java new file mode 100644 index 0000000000..251c4ed061 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PacketMirroringsSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for PacketMirrorings client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.packet-mirrorings") +public class PacketMirroringsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ProjectsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ProjectsSpringAutoConfiguration.java new file mode 100644 index 0000000000..46c0196c5b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ProjectsSpringAutoConfiguration.java @@ -0,0 +1,237 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ProjectsClient; +import com.google.cloud.compute.v1.ProjectsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ProjectsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ProjectsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.projects.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(ProjectsSpringProperties.class) +public class ProjectsSpringAutoConfiguration { + private final ProjectsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(ProjectsSpringAutoConfiguration.class); + + protected ProjectsSpringAutoConfiguration( + ProjectsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Projects-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultProjectsTransportChannelProvider") + public TransportChannelProvider defaultProjectsTransportChannelProvider() { + return ProjectsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ProjectsSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultProjectsTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ProjectsSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ProjectsSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public ProjectsSettings projectsSettings( + @Qualifier("defaultProjectsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ProjectsSettings.Builder clientSettingsBuilder = ProjectsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ProjectsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getXpnHostRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getXpnHostSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getXpnHostSettings().setRetrySettings(getXpnHostRetrySettings); + + RetrySettings getXpnResourcesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getXpnResourcesSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .getXpnResourcesSettings() + .setRetrySettings(getXpnResourcesRetrySettings); + + RetrySettings listXpnHostsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listXpnHostsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listXpnHostsSettings().setRetrySettings(listXpnHostsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getXpnHostRetry = clientProperties.getGetXpnHostRetry(); + if (getXpnHostRetry != null) { + RetrySettings getXpnHostRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getXpnHostSettings().getRetrySettings(), getXpnHostRetry); + clientSettingsBuilder.getXpnHostSettings().setRetrySettings(getXpnHostRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getXpnHost from properties."); + } + } + Retry getXpnResourcesRetry = clientProperties.getGetXpnResourcesRetry(); + if (getXpnResourcesRetry != null) { + RetrySettings getXpnResourcesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getXpnResourcesSettings().getRetrySettings(), + getXpnResourcesRetry); + clientSettingsBuilder + .getXpnResourcesSettings() + .setRetrySettings(getXpnResourcesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getXpnResources from properties."); + } + } + Retry listXpnHostsRetry = clientProperties.getListXpnHostsRetry(); + if (listXpnHostsRetry != null) { + RetrySettings listXpnHostsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listXpnHostsSettings().getRetrySettings(), listXpnHostsRetry); + clientSettingsBuilder.listXpnHostsSettings().setRetrySettings(listXpnHostsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for listXpnHosts from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ProjectsClient bean configured with ProjectsSettings. + * + * @param projectsSettings settings to configure an instance of client bean. + * @return a {@link ProjectsClient} bean configured with {@link ProjectsSettings} + */ + @Bean + @ConditionalOnMissingBean + public ProjectsClient projectsClient(ProjectsSettings projectsSettings) throws IOException { + return ProjectsClient.create(projectsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-projects"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ProjectsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ProjectsSpringProperties.java new file mode 100644 index 0000000000..2f24de48ed --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ProjectsSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Projects client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.projects") +public class ProjectsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getXpnHost. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getXpnHostRetry; + /** + * Allow override of retry settings at method-level for getXpnResources. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getXpnResourcesRetry; + /** + * Allow override of retry settings at method-level for listXpnHosts. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listXpnHostsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetXpnHostRetry() { + return this.getXpnHostRetry; + } + + public void setGetXpnHostRetry(Retry getXpnHostRetry) { + this.getXpnHostRetry = getXpnHostRetry; + } + + public Retry getGetXpnResourcesRetry() { + return this.getXpnResourcesRetry; + } + + public void setGetXpnResourcesRetry(Retry getXpnResourcesRetry) { + this.getXpnResourcesRetry = getXpnResourcesRetry; + } + + public Retry getListXpnHostsRetry() { + return this.listXpnHostsRetry; + } + + public void setListXpnHostsRetry(Retry listXpnHostsRetry) { + this.listXpnHostsRetry = listXpnHostsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicAdvertisedPrefixesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicAdvertisedPrefixesSpringAutoConfiguration.java new file mode 100644 index 0000000000..6f3462afac --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicAdvertisedPrefixesSpringAutoConfiguration.java @@ -0,0 +1,211 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.PublicAdvertisedPrefixesClient; +import com.google.cloud.compute.v1.PublicAdvertisedPrefixesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link PublicAdvertisedPrefixesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(PublicAdvertisedPrefixesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.public-advertised-prefixes.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(PublicAdvertisedPrefixesSpringProperties.class) +public class PublicAdvertisedPrefixesSpringAutoConfiguration { + private final PublicAdvertisedPrefixesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(PublicAdvertisedPrefixesSpringAutoConfiguration.class); + + protected PublicAdvertisedPrefixesSpringAutoConfiguration( + PublicAdvertisedPrefixesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from PublicAdvertisedPrefixes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultPublicAdvertisedPrefixesTransportChannelProvider") + public TransportChannelProvider defaultPublicAdvertisedPrefixesTransportChannelProvider() { + return PublicAdvertisedPrefixesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a PublicAdvertisedPrefixesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultPublicAdvertisedPrefixesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in PublicAdvertisedPrefixesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link PublicAdvertisedPrefixesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public PublicAdvertisedPrefixesSettings publicAdvertisedPrefixesSettings( + @Qualifier("defaultPublicAdvertisedPrefixesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + PublicAdvertisedPrefixesSettings.Builder clientSettingsBuilder = + PublicAdvertisedPrefixesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + PublicAdvertisedPrefixesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a PublicAdvertisedPrefixesClient bean configured with + * PublicAdvertisedPrefixesSettings. + * + * @param publicAdvertisedPrefixesSettings settings to configure an instance of client bean. + * @return a {@link PublicAdvertisedPrefixesClient} bean configured with {@link + * PublicAdvertisedPrefixesSettings} + */ + @Bean + @ConditionalOnMissingBean + public PublicAdvertisedPrefixesClient publicAdvertisedPrefixesClient( + PublicAdvertisedPrefixesSettings publicAdvertisedPrefixesSettings) throws IOException { + return PublicAdvertisedPrefixesClient.create(publicAdvertisedPrefixesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-public-advertised-prefixes"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicAdvertisedPrefixesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicAdvertisedPrefixesSpringProperties.java new file mode 100644 index 0000000000..67e9989e8e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicAdvertisedPrefixesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for PublicAdvertisedPrefixes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.public-advertised-prefixes") +public class PublicAdvertisedPrefixesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicDelegatedPrefixesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicDelegatedPrefixesSpringAutoConfiguration.java new file mode 100644 index 0000000000..d17531dee6 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicDelegatedPrefixesSpringAutoConfiguration.java @@ -0,0 +1,226 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.PublicDelegatedPrefixesClient; +import com.google.cloud.compute.v1.PublicDelegatedPrefixesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link PublicDelegatedPrefixesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(PublicDelegatedPrefixesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.public-delegated-prefixes.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(PublicDelegatedPrefixesSpringProperties.class) +public class PublicDelegatedPrefixesSpringAutoConfiguration { + private final PublicDelegatedPrefixesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(PublicDelegatedPrefixesSpringAutoConfiguration.class); + + protected PublicDelegatedPrefixesSpringAutoConfiguration( + PublicDelegatedPrefixesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from PublicDelegatedPrefixes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultPublicDelegatedPrefixesTransportChannelProvider") + public TransportChannelProvider defaultPublicDelegatedPrefixesTransportChannelProvider() { + return PublicDelegatedPrefixesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a PublicDelegatedPrefixesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultPublicDelegatedPrefixesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in PublicDelegatedPrefixesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link PublicDelegatedPrefixesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public PublicDelegatedPrefixesSettings publicDelegatedPrefixesSettings( + @Qualifier("defaultPublicDelegatedPrefixesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + PublicDelegatedPrefixesSettings.Builder clientSettingsBuilder = + PublicDelegatedPrefixesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + PublicDelegatedPrefixesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a PublicDelegatedPrefixesClient bean configured with PublicDelegatedPrefixesSettings. + * + * @param publicDelegatedPrefixesSettings settings to configure an instance of client bean. + * @return a {@link PublicDelegatedPrefixesClient} bean configured with {@link + * PublicDelegatedPrefixesSettings} + */ + @Bean + @ConditionalOnMissingBean + public PublicDelegatedPrefixesClient publicDelegatedPrefixesClient( + PublicDelegatedPrefixesSettings publicDelegatedPrefixesSettings) throws IOException { + return PublicDelegatedPrefixesClient.create(publicDelegatedPrefixesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-public-delegated-prefixes"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicDelegatedPrefixesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicDelegatedPrefixesSpringProperties.java new file mode 100644 index 0000000000..01cf86679a --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/PublicDelegatedPrefixesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for PublicDelegatedPrefixes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.public-delegated-prefixes") +public class PublicDelegatedPrefixesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionAutoscalersSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionAutoscalersSpringAutoConfiguration.java new file mode 100644 index 0000000000..e283a4a4b6 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionAutoscalersSpringAutoConfiguration.java @@ -0,0 +1,209 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionAutoscalersClient; +import com.google.cloud.compute.v1.RegionAutoscalersSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionAutoscalersClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionAutoscalersClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-autoscalers.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionAutoscalersSpringProperties.class) +public class RegionAutoscalersSpringAutoConfiguration { + private final RegionAutoscalersSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionAutoscalersSpringAutoConfiguration.class); + + protected RegionAutoscalersSpringAutoConfiguration( + RegionAutoscalersSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionAutoscalers-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionAutoscalersTransportChannelProvider") + public TransportChannelProvider defaultRegionAutoscalersTransportChannelProvider() { + return RegionAutoscalersSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionAutoscalersSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultRegionAutoscalersTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionAutoscalersSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionAutoscalersSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionAutoscalersSettings regionAutoscalersSettings( + @Qualifier("defaultRegionAutoscalersTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionAutoscalersSettings.Builder clientSettingsBuilder = + RegionAutoscalersSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionAutoscalersSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionAutoscalersClient bean configured with RegionAutoscalersSettings. + * + * @param regionAutoscalersSettings settings to configure an instance of client bean. + * @return a {@link RegionAutoscalersClient} bean configured with {@link + * RegionAutoscalersSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionAutoscalersClient regionAutoscalersClient( + RegionAutoscalersSettings regionAutoscalersSettings) throws IOException { + return RegionAutoscalersClient.create(regionAutoscalersSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-autoscalers"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionAutoscalersSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionAutoscalersSpringProperties.java new file mode 100644 index 0000000000..660dabe0a1 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionAutoscalersSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionAutoscalers client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-autoscalers") +public class RegionAutoscalersSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionBackendServicesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionBackendServicesSpringAutoConfiguration.java new file mode 100644 index 0000000000..2629a9e472 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionBackendServicesSpringAutoConfiguration.java @@ -0,0 +1,255 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionBackendServicesClient; +import com.google.cloud.compute.v1.RegionBackendServicesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionBackendServicesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionBackendServicesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-backend-services.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionBackendServicesSpringProperties.class) +public class RegionBackendServicesSpringAutoConfiguration { + private final RegionBackendServicesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionBackendServicesSpringAutoConfiguration.class); + + protected RegionBackendServicesSpringAutoConfiguration( + RegionBackendServicesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionBackendServices-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionBackendServicesTransportChannelProvider") + public TransportChannelProvider defaultRegionBackendServicesTransportChannelProvider() { + return RegionBackendServicesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionBackendServicesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultRegionBackendServicesTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionBackendServicesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionBackendServicesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionBackendServicesSettings regionBackendServicesSettings( + @Qualifier("defaultRegionBackendServicesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionBackendServicesSettings.Builder clientSettingsBuilder = + RegionBackendServicesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionBackendServicesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getHealthRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getHealthSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getHealthSettings().setRetrySettings(getHealthRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getHealthRetry = clientProperties.getGetHealthRetry(); + if (getHealthRetry != null) { + RetrySettings getHealthRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getHealthSettings().getRetrySettings(), getHealthRetry); + clientSettingsBuilder.getHealthSettings().setRetrySettings(getHealthRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getHealth from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionBackendServicesClient bean configured with RegionBackendServicesSettings. + * + * @param regionBackendServicesSettings settings to configure an instance of client bean. + * @return a {@link RegionBackendServicesClient} bean configured with {@link + * RegionBackendServicesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionBackendServicesClient regionBackendServicesClient( + RegionBackendServicesSettings regionBackendServicesSettings) throws IOException { + return RegionBackendServicesClient.create(regionBackendServicesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-backend-services"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionBackendServicesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionBackendServicesSpringProperties.java new file mode 100644 index 0000000000..1f5e9ef0d5 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionBackendServicesSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionBackendServices client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-backend-services") +public class RegionBackendServicesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getHealth. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getHealthRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetHealthRetry() { + return this.getHealthRetry; + } + + public void setGetHealthRetry(Retry getHealthRetry) { + this.getHealthRetry = getHealthRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionCommitmentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionCommitmentsSpringAutoConfiguration.java new file mode 100644 index 0000000000..f68474ad78 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionCommitmentsSpringAutoConfiguration.java @@ -0,0 +1,225 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionCommitmentsClient; +import com.google.cloud.compute.v1.RegionCommitmentsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionCommitmentsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionCommitmentsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-commitments.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionCommitmentsSpringProperties.class) +public class RegionCommitmentsSpringAutoConfiguration { + private final RegionCommitmentsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionCommitmentsSpringAutoConfiguration.class); + + protected RegionCommitmentsSpringAutoConfiguration( + RegionCommitmentsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionCommitments-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionCommitmentsTransportChannelProvider") + public TransportChannelProvider defaultRegionCommitmentsTransportChannelProvider() { + return RegionCommitmentsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionCommitmentsSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultRegionCommitmentsTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionCommitmentsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionCommitmentsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionCommitmentsSettings regionCommitmentsSettings( + @Qualifier("defaultRegionCommitmentsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionCommitmentsSettings.Builder clientSettingsBuilder = + RegionCommitmentsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionCommitmentsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionCommitmentsClient bean configured with RegionCommitmentsSettings. + * + * @param regionCommitmentsSettings settings to configure an instance of client bean. + * @return a {@link RegionCommitmentsClient} bean configured with {@link + * RegionCommitmentsSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionCommitmentsClient regionCommitmentsClient( + RegionCommitmentsSettings regionCommitmentsSettings) throws IOException { + return RegionCommitmentsClient.create(regionCommitmentsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-commitments"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionCommitmentsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionCommitmentsSpringProperties.java new file mode 100644 index 0000000000..baa97f2db3 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionCommitmentsSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionCommitments client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-commitments") +public class RegionCommitmentsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDiskTypesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDiskTypesSpringAutoConfiguration.java new file mode 100644 index 0000000000..51122e2f36 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDiskTypesSpringAutoConfiguration.java @@ -0,0 +1,206 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionDiskTypesClient; +import com.google.cloud.compute.v1.RegionDiskTypesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionDiskTypesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionDiskTypesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-disk-types.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionDiskTypesSpringProperties.class) +public class RegionDiskTypesSpringAutoConfiguration { + private final RegionDiskTypesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(RegionDiskTypesSpringAutoConfiguration.class); + + protected RegionDiskTypesSpringAutoConfiguration( + RegionDiskTypesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionDiskTypes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionDiskTypesTransportChannelProvider") + public TransportChannelProvider defaultRegionDiskTypesTransportChannelProvider() { + return RegionDiskTypesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionDiskTypesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultRegionDiskTypesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionDiskTypesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionDiskTypesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionDiskTypesSettings regionDiskTypesSettings( + @Qualifier("defaultRegionDiskTypesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionDiskTypesSettings.Builder clientSettingsBuilder = RegionDiskTypesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionDiskTypesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionDiskTypesClient bean configured with RegionDiskTypesSettings. + * + * @param regionDiskTypesSettings settings to configure an instance of client bean. + * @return a {@link RegionDiskTypesClient} bean configured with {@link RegionDiskTypesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionDiskTypesClient regionDiskTypesClient( + RegionDiskTypesSettings regionDiskTypesSettings) throws IOException { + return RegionDiskTypesClient.create(regionDiskTypesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-disk-types"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDiskTypesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDiskTypesSpringProperties.java new file mode 100644 index 0000000000..5849383948 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDiskTypesSpringProperties.java @@ -0,0 +1,101 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionDiskTypes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-disk-types") +public class RegionDiskTypesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDisksSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDisksSpringAutoConfiguration.java new file mode 100644 index 0000000000..6f02656145 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDisksSpringAutoConfiguration.java @@ -0,0 +1,256 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionDisksClient; +import com.google.cloud.compute.v1.RegionDisksSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionDisksClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionDisksClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-disks.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionDisksSpringProperties.class) +public class RegionDisksSpringAutoConfiguration { + private final RegionDisksSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(RegionDisksSpringAutoConfiguration.class); + + protected RegionDisksSpringAutoConfiguration( + RegionDisksSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionDisks-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionDisksTransportChannelProvider") + public TransportChannelProvider defaultRegionDisksTransportChannelProvider() { + return RegionDisksSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionDisksSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultRegionDisksTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionDisksSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionDisksSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionDisksSettings regionDisksSettings( + @Qualifier("defaultRegionDisksTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionDisksSettings.Builder clientSettingsBuilder = RegionDisksSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionDisksSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionDisksClient bean configured with RegionDisksSettings. + * + * @param regionDisksSettings settings to configure an instance of client bean. + * @return a {@link RegionDisksClient} bean configured with {@link RegionDisksSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionDisksClient regionDisksClient(RegionDisksSettings regionDisksSettings) + throws IOException { + return RegionDisksClient.create(regionDisksSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-disks"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDisksSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDisksSpringProperties.java new file mode 100644 index 0000000000..5333171aec --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionDisksSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionDisks client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-disks") +public class RegionDisksSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthCheckServicesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthCheckServicesSpringAutoConfiguration.java new file mode 100644 index 0000000000..e2fac9380b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthCheckServicesSpringAutoConfiguration.java @@ -0,0 +1,211 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionHealthCheckServicesClient; +import com.google.cloud.compute.v1.RegionHealthCheckServicesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionHealthCheckServicesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionHealthCheckServicesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-health-check-services.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionHealthCheckServicesSpringProperties.class) +public class RegionHealthCheckServicesSpringAutoConfiguration { + private final RegionHealthCheckServicesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionHealthCheckServicesSpringAutoConfiguration.class); + + protected RegionHealthCheckServicesSpringAutoConfiguration( + RegionHealthCheckServicesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionHealthCheckServices-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionHealthCheckServicesTransportChannelProvider") + public TransportChannelProvider defaultRegionHealthCheckServicesTransportChannelProvider() { + return RegionHealthCheckServicesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionHealthCheckServicesSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultRegionHealthCheckServicesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionHealthCheckServicesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionHealthCheckServicesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionHealthCheckServicesSettings regionHealthCheckServicesSettings( + @Qualifier("defaultRegionHealthCheckServicesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionHealthCheckServicesSettings.Builder clientSettingsBuilder = + RegionHealthCheckServicesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionHealthCheckServicesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionHealthCheckServicesClient bean configured with + * RegionHealthCheckServicesSettings. + * + * @param regionHealthCheckServicesSettings settings to configure an instance of client bean. + * @return a {@link RegionHealthCheckServicesClient} bean configured with {@link + * RegionHealthCheckServicesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionHealthCheckServicesClient regionHealthCheckServicesClient( + RegionHealthCheckServicesSettings regionHealthCheckServicesSettings) throws IOException { + return RegionHealthCheckServicesClient.create(regionHealthCheckServicesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-health-check-services"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthCheckServicesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthCheckServicesSpringProperties.java new file mode 100644 index 0000000000..bd6cfb4956 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthCheckServicesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionHealthCheckServices client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-health-check-services") +public class RegionHealthCheckServicesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthChecksSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthChecksSpringAutoConfiguration.java new file mode 100644 index 0000000000..ec229ca4d2 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthChecksSpringAutoConfiguration.java @@ -0,0 +1,209 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionHealthChecksClient; +import com.google.cloud.compute.v1.RegionHealthChecksSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionHealthChecksClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionHealthChecksClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-health-checks.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionHealthChecksSpringProperties.class) +public class RegionHealthChecksSpringAutoConfiguration { + private final RegionHealthChecksSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionHealthChecksSpringAutoConfiguration.class); + + protected RegionHealthChecksSpringAutoConfiguration( + RegionHealthChecksSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionHealthChecks-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionHealthChecksTransportChannelProvider") + public TransportChannelProvider defaultRegionHealthChecksTransportChannelProvider() { + return RegionHealthChecksSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionHealthChecksSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultRegionHealthChecksTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionHealthChecksSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionHealthChecksSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionHealthChecksSettings regionHealthChecksSettings( + @Qualifier("defaultRegionHealthChecksTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionHealthChecksSettings.Builder clientSettingsBuilder = + RegionHealthChecksSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionHealthChecksSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionHealthChecksClient bean configured with RegionHealthChecksSettings. + * + * @param regionHealthChecksSettings settings to configure an instance of client bean. + * @return a {@link RegionHealthChecksClient} bean configured with {@link + * RegionHealthChecksSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionHealthChecksClient regionHealthChecksClient( + RegionHealthChecksSettings regionHealthChecksSettings) throws IOException { + return RegionHealthChecksClient.create(regionHealthChecksSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-health-checks"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthChecksSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthChecksSpringProperties.java new file mode 100644 index 0000000000..317fe0d4d0 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionHealthChecksSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionHealthChecks client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-health-checks") +public class RegionHealthChecksSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupManagersSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupManagersSpringAutoConfiguration.java new file mode 100644 index 0000000000..1b215860af --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupManagersSpringAutoConfiguration.java @@ -0,0 +1,270 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionInstanceGroupManagersClient; +import com.google.cloud.compute.v1.RegionInstanceGroupManagersSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionInstanceGroupManagersClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionInstanceGroupManagersClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-instance-group-managers.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionInstanceGroupManagersSpringProperties.class) +public class RegionInstanceGroupManagersSpringAutoConfiguration { + private final RegionInstanceGroupManagersSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionInstanceGroupManagersSpringAutoConfiguration.class); + + protected RegionInstanceGroupManagersSpringAutoConfiguration( + RegionInstanceGroupManagersSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionInstanceGroupManagers-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionInstanceGroupManagersTransportChannelProvider") + public TransportChannelProvider defaultRegionInstanceGroupManagersTransportChannelProvider() { + return RegionInstanceGroupManagersSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionInstanceGroupManagersSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultRegionInstanceGroupManagersTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionInstanceGroupManagersSpringProperties. Method-level properties will take precedence + * over service-level properties if available, and client library defaults will be used if neither + * are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionInstanceGroupManagersSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionInstanceGroupManagersSettings regionInstanceGroupManagersSettings( + @Qualifier("defaultRegionInstanceGroupManagersTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionInstanceGroupManagersSettings.Builder clientSettingsBuilder = + RegionInstanceGroupManagersSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionInstanceGroupManagersSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listErrorsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listErrorsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listErrorsSettings().setRetrySettings(listErrorsRetrySettings); + + RetrySettings listManagedInstancesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listManagedInstancesSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listManagedInstancesSettings() + .setRetrySettings(listManagedInstancesRetrySettings); + + RetrySettings listPerInstanceConfigsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listPerInstanceConfigsSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listPerInstanceConfigsSettings() + .setRetrySettings(listPerInstanceConfigsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listErrorsRetry = clientProperties.getListErrorsRetry(); + if (listErrorsRetry != null) { + RetrySettings listErrorsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listErrorsSettings().getRetrySettings(), listErrorsRetry); + clientSettingsBuilder.listErrorsSettings().setRetrySettings(listErrorsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for listErrors from properties."); + } + } + Retry listManagedInstancesRetry = clientProperties.getListManagedInstancesRetry(); + if (listManagedInstancesRetry != null) { + RetrySettings listManagedInstancesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listManagedInstancesSettings().getRetrySettings(), + listManagedInstancesRetry); + clientSettingsBuilder + .listManagedInstancesSettings() + .setRetrySettings(listManagedInstancesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listManagedInstances from properties."); + } + } + Retry listPerInstanceConfigsRetry = clientProperties.getListPerInstanceConfigsRetry(); + if (listPerInstanceConfigsRetry != null) { + RetrySettings listPerInstanceConfigsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listPerInstanceConfigsSettings().getRetrySettings(), + listPerInstanceConfigsRetry); + clientSettingsBuilder + .listPerInstanceConfigsSettings() + .setRetrySettings(listPerInstanceConfigsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listPerInstanceConfigs from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionInstanceGroupManagersClient bean configured with + * RegionInstanceGroupManagersSettings. + * + * @param regionInstanceGroupManagersSettings settings to configure an instance of client bean. + * @return a {@link RegionInstanceGroupManagersClient} bean configured with {@link + * RegionInstanceGroupManagersSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionInstanceGroupManagersClient regionInstanceGroupManagersClient( + RegionInstanceGroupManagersSettings regionInstanceGroupManagersSettings) throws IOException { + return RegionInstanceGroupManagersClient.create(regionInstanceGroupManagersSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-instance-group-managers"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupManagersSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupManagersSpringProperties.java new file mode 100644 index 0000000000..1dfc8e6535 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupManagersSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionInstanceGroupManagers client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-instance-group-managers") +public class RegionInstanceGroupManagersSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listErrors. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listErrorsRetry; + /** + * Allow override of retry settings at method-level for listManagedInstances. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listManagedInstancesRetry; + /** + * Allow override of retry settings at method-level for listPerInstanceConfigs. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listPerInstanceConfigsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListErrorsRetry() { + return this.listErrorsRetry; + } + + public void setListErrorsRetry(Retry listErrorsRetry) { + this.listErrorsRetry = listErrorsRetry; + } + + public Retry getListManagedInstancesRetry() { + return this.listManagedInstancesRetry; + } + + public void setListManagedInstancesRetry(Retry listManagedInstancesRetry) { + this.listManagedInstancesRetry = listManagedInstancesRetry; + } + + public Retry getListPerInstanceConfigsRetry() { + return this.listPerInstanceConfigsRetry; + } + + public void setListPerInstanceConfigsRetry(Retry listPerInstanceConfigsRetry) { + this.listPerInstanceConfigsRetry = listPerInstanceConfigsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupsSpringAutoConfiguration.java new file mode 100644 index 0000000000..eee02db42f --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupsSpringAutoConfiguration.java @@ -0,0 +1,225 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionInstanceGroupsClient; +import com.google.cloud.compute.v1.RegionInstanceGroupsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionInstanceGroupsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionInstanceGroupsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-instance-groups.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionInstanceGroupsSpringProperties.class) +public class RegionInstanceGroupsSpringAutoConfiguration { + private final RegionInstanceGroupsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionInstanceGroupsSpringAutoConfiguration.class); + + protected RegionInstanceGroupsSpringAutoConfiguration( + RegionInstanceGroupsSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionInstanceGroups-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionInstanceGroupsTransportChannelProvider") + public TransportChannelProvider defaultRegionInstanceGroupsTransportChannelProvider() { + return RegionInstanceGroupsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionInstanceGroupsSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultRegionInstanceGroupsTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionInstanceGroupsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionInstanceGroupsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionInstanceGroupsSettings regionInstanceGroupsSettings( + @Qualifier("defaultRegionInstanceGroupsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionInstanceGroupsSettings.Builder clientSettingsBuilder = + RegionInstanceGroupsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionInstanceGroupsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listInstancesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listInstancesSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listInstancesSettings().setRetrySettings(listInstancesRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listInstancesRetry = clientProperties.getListInstancesRetry(); + if (listInstancesRetry != null) { + RetrySettings listInstancesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listInstancesSettings().getRetrySettings(), listInstancesRetry); + clientSettingsBuilder.listInstancesSettings().setRetrySettings(listInstancesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for listInstances from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionInstanceGroupsClient bean configured with RegionInstanceGroupsSettings. + * + * @param regionInstanceGroupsSettings settings to configure an instance of client bean. + * @return a {@link RegionInstanceGroupsClient} bean configured with {@link + * RegionInstanceGroupsSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionInstanceGroupsClient regionInstanceGroupsClient( + RegionInstanceGroupsSettings regionInstanceGroupsSettings) throws IOException { + return RegionInstanceGroupsClient.create(regionInstanceGroupsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-instance-groups"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupsSpringProperties.java new file mode 100644 index 0000000000..d56267ece8 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceGroupsSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionInstanceGroups client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-instance-groups") +public class RegionInstanceGroupsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listInstances. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listInstancesRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListInstancesRetry() { + return this.listInstancesRetry; + } + + public void setListInstancesRetry(Retry listInstancesRetry) { + this.listInstancesRetry = listInstancesRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceTemplatesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceTemplatesSpringAutoConfiguration.java new file mode 100644 index 0000000000..f6477016c6 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceTemplatesSpringAutoConfiguration.java @@ -0,0 +1,210 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionInstanceTemplatesClient; +import com.google.cloud.compute.v1.RegionInstanceTemplatesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionInstanceTemplatesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionInstanceTemplatesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-instance-templates.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionInstanceTemplatesSpringProperties.class) +public class RegionInstanceTemplatesSpringAutoConfiguration { + private final RegionInstanceTemplatesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionInstanceTemplatesSpringAutoConfiguration.class); + + protected RegionInstanceTemplatesSpringAutoConfiguration( + RegionInstanceTemplatesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionInstanceTemplates-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionInstanceTemplatesTransportChannelProvider") + public TransportChannelProvider defaultRegionInstanceTemplatesTransportChannelProvider() { + return RegionInstanceTemplatesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionInstanceTemplatesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultRegionInstanceTemplatesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionInstanceTemplatesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionInstanceTemplatesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionInstanceTemplatesSettings regionInstanceTemplatesSettings( + @Qualifier("defaultRegionInstanceTemplatesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionInstanceTemplatesSettings.Builder clientSettingsBuilder = + RegionInstanceTemplatesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionInstanceTemplatesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionInstanceTemplatesClient bean configured with RegionInstanceTemplatesSettings. + * + * @param regionInstanceTemplatesSettings settings to configure an instance of client bean. + * @return a {@link RegionInstanceTemplatesClient} bean configured with {@link + * RegionInstanceTemplatesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionInstanceTemplatesClient regionInstanceTemplatesClient( + RegionInstanceTemplatesSettings regionInstanceTemplatesSettings) throws IOException { + return RegionInstanceTemplatesClient.create(regionInstanceTemplatesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-instance-templates"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceTemplatesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceTemplatesSpringProperties.java new file mode 100644 index 0000000000..0ebbfcb72c --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstanceTemplatesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionInstanceTemplates client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-instance-templates") +public class RegionInstanceTemplatesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstancesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstancesSpringAutoConfiguration.java new file mode 100644 index 0000000000..b07f9dbffa --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstancesSpringAutoConfiguration.java @@ -0,0 +1,174 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionInstancesClient; +import com.google.cloud.compute.v1.RegionInstancesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionInstancesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionInstancesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-instances.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionInstancesSpringProperties.class) +public class RegionInstancesSpringAutoConfiguration { + private final RegionInstancesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(RegionInstancesSpringAutoConfiguration.class); + + protected RegionInstancesSpringAutoConfiguration( + RegionInstancesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionInstances-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionInstancesTransportChannelProvider") + public TransportChannelProvider defaultRegionInstancesTransportChannelProvider() { + return RegionInstancesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionInstancesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultRegionInstancesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionInstancesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionInstancesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionInstancesSettings regionInstancesSettings( + @Qualifier("defaultRegionInstancesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionInstancesSettings.Builder clientSettingsBuilder = RegionInstancesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionInstancesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionInstancesClient bean configured with RegionInstancesSettings. + * + * @param regionInstancesSettings settings to configure an instance of client bean. + * @return a {@link RegionInstancesClient} bean configured with {@link RegionInstancesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionInstancesClient regionInstancesClient( + RegionInstancesSettings regionInstancesSettings) throws IOException { + return RegionInstancesClient.create(regionInstancesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-instances"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstancesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstancesSpringProperties.java new file mode 100644 index 0000000000..6ea7829ac6 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionInstancesSpringProperties.java @@ -0,0 +1,74 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionInstances client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-instances") +public class RegionInstancesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkEndpointGroupsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkEndpointGroupsSpringAutoConfiguration.java new file mode 100644 index 0000000000..548296a79e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkEndpointGroupsSpringAutoConfiguration.java @@ -0,0 +1,211 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionNetworkEndpointGroupsClient; +import com.google.cloud.compute.v1.RegionNetworkEndpointGroupsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionNetworkEndpointGroupsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionNetworkEndpointGroupsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-network-endpoint-groups.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionNetworkEndpointGroupsSpringProperties.class) +public class RegionNetworkEndpointGroupsSpringAutoConfiguration { + private final RegionNetworkEndpointGroupsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionNetworkEndpointGroupsSpringAutoConfiguration.class); + + protected RegionNetworkEndpointGroupsSpringAutoConfiguration( + RegionNetworkEndpointGroupsSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionNetworkEndpointGroups-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionNetworkEndpointGroupsTransportChannelProvider") + public TransportChannelProvider defaultRegionNetworkEndpointGroupsTransportChannelProvider() { + return RegionNetworkEndpointGroupsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionNetworkEndpointGroupsSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultRegionNetworkEndpointGroupsTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionNetworkEndpointGroupsSpringProperties. Method-level properties will take precedence + * over service-level properties if available, and client library defaults will be used if neither + * are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionNetworkEndpointGroupsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionNetworkEndpointGroupsSettings regionNetworkEndpointGroupsSettings( + @Qualifier("defaultRegionNetworkEndpointGroupsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionNetworkEndpointGroupsSettings.Builder clientSettingsBuilder = + RegionNetworkEndpointGroupsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionNetworkEndpointGroupsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionNetworkEndpointGroupsClient bean configured with + * RegionNetworkEndpointGroupsSettings. + * + * @param regionNetworkEndpointGroupsSettings settings to configure an instance of client bean. + * @return a {@link RegionNetworkEndpointGroupsClient} bean configured with {@link + * RegionNetworkEndpointGroupsSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionNetworkEndpointGroupsClient regionNetworkEndpointGroupsClient( + RegionNetworkEndpointGroupsSettings regionNetworkEndpointGroupsSettings) throws IOException { + return RegionNetworkEndpointGroupsClient.create(regionNetworkEndpointGroupsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-network-endpoint-groups"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkEndpointGroupsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkEndpointGroupsSpringProperties.java new file mode 100644 index 0000000000..b86fcfed53 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkEndpointGroupsSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionNetworkEndpointGroups client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-network-endpoint-groups") +public class RegionNetworkEndpointGroupsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkFirewallPoliciesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkFirewallPoliciesSpringAutoConfiguration.java new file mode 100644 index 0000000000..c4d527489f --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkFirewallPoliciesSpringAutoConfiguration.java @@ -0,0 +1,316 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionNetworkFirewallPoliciesClient; +import com.google.cloud.compute.v1.RegionNetworkFirewallPoliciesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionNetworkFirewallPoliciesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionNetworkFirewallPoliciesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-network-firewall-policies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionNetworkFirewallPoliciesSpringProperties.class) +public class RegionNetworkFirewallPoliciesSpringAutoConfiguration { + private final RegionNetworkFirewallPoliciesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionNetworkFirewallPoliciesSpringAutoConfiguration.class); + + protected RegionNetworkFirewallPoliciesSpringAutoConfiguration( + RegionNetworkFirewallPoliciesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionNetworkFirewallPolicies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionNetworkFirewallPoliciesTransportChannelProvider") + public TransportChannelProvider defaultRegionNetworkFirewallPoliciesTransportChannelProvider() { + return RegionNetworkFirewallPoliciesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionNetworkFirewallPoliciesSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultRegionNetworkFirewallPoliciesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionNetworkFirewallPoliciesSpringProperties. Method-level properties will take precedence + * over service-level properties if available, and client library defaults will be used if neither + * are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionNetworkFirewallPoliciesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionNetworkFirewallPoliciesSettings regionNetworkFirewallPoliciesSettings( + @Qualifier("defaultRegionNetworkFirewallPoliciesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionNetworkFirewallPoliciesSettings.Builder clientSettingsBuilder = + RegionNetworkFirewallPoliciesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionNetworkFirewallPoliciesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getAssociationRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getAssociationSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getAssociationSettings().setRetrySettings(getAssociationRetrySettings); + + RetrySettings getEffectiveFirewallsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getEffectiveFirewallsSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .getEffectiveFirewallsSettings() + .setRetrySettings(getEffectiveFirewallsRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings getRuleRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRuleSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getRuleSettings().setRetrySettings(getRuleRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getAssociationRetry = clientProperties.getGetAssociationRetry(); + if (getAssociationRetry != null) { + RetrySettings getAssociationRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getAssociationSettings().getRetrySettings(), + getAssociationRetry); + clientSettingsBuilder.getAssociationSettings().setRetrySettings(getAssociationRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getAssociation from properties."); + } + } + Retry getEffectiveFirewallsRetry = clientProperties.getGetEffectiveFirewallsRetry(); + if (getEffectiveFirewallsRetry != null) { + RetrySettings getEffectiveFirewallsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getEffectiveFirewallsSettings().getRetrySettings(), + getEffectiveFirewallsRetry); + clientSettingsBuilder + .getEffectiveFirewallsSettings() + .setRetrySettings(getEffectiveFirewallsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for getEffectiveFirewalls from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry getRuleRetry = clientProperties.getGetRuleRetry(); + if (getRuleRetry != null) { + RetrySettings getRuleRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRuleSettings().getRetrySettings(), getRuleRetry); + clientSettingsBuilder.getRuleSettings().setRetrySettings(getRuleRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getRule from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionNetworkFirewallPoliciesClient bean configured with + * RegionNetworkFirewallPoliciesSettings. + * + * @param regionNetworkFirewallPoliciesSettings settings to configure an instance of client bean. + * @return a {@link RegionNetworkFirewallPoliciesClient} bean configured with {@link + * RegionNetworkFirewallPoliciesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionNetworkFirewallPoliciesClient regionNetworkFirewallPoliciesClient( + RegionNetworkFirewallPoliciesSettings regionNetworkFirewallPoliciesSettings) + throws IOException { + return RegionNetworkFirewallPoliciesClient.create(regionNetworkFirewallPoliciesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-network-firewall-policies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkFirewallPoliciesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkFirewallPoliciesSpringProperties.java new file mode 100644 index 0000000000..a3bea0e243 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNetworkFirewallPoliciesSpringProperties.java @@ -0,0 +1,178 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionNetworkFirewallPolicies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-network-firewall-policies") +public class RegionNetworkFirewallPoliciesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getAssociation. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getAssociationRetry; + /** + * Allow override of retry settings at method-level for getEffectiveFirewalls. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getEffectiveFirewallsRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for getRule. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRuleRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetAssociationRetry() { + return this.getAssociationRetry; + } + + public void setGetAssociationRetry(Retry getAssociationRetry) { + this.getAssociationRetry = getAssociationRetry; + } + + public Retry getGetEffectiveFirewallsRetry() { + return this.getEffectiveFirewallsRetry; + } + + public void setGetEffectiveFirewallsRetry(Retry getEffectiveFirewallsRetry) { + this.getEffectiveFirewallsRetry = getEffectiveFirewallsRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getGetRuleRetry() { + return this.getRuleRetry; + } + + public void setGetRuleRetry(Retry getRuleRetry) { + this.getRuleRetry = getRuleRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNotificationEndpointsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNotificationEndpointsSpringAutoConfiguration.java new file mode 100644 index 0000000000..e81f21138a --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNotificationEndpointsSpringAutoConfiguration.java @@ -0,0 +1,211 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionNotificationEndpointsClient; +import com.google.cloud.compute.v1.RegionNotificationEndpointsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionNotificationEndpointsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionNotificationEndpointsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-notification-endpoints.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionNotificationEndpointsSpringProperties.class) +public class RegionNotificationEndpointsSpringAutoConfiguration { + private final RegionNotificationEndpointsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionNotificationEndpointsSpringAutoConfiguration.class); + + protected RegionNotificationEndpointsSpringAutoConfiguration( + RegionNotificationEndpointsSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionNotificationEndpoints-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionNotificationEndpointsTransportChannelProvider") + public TransportChannelProvider defaultRegionNotificationEndpointsTransportChannelProvider() { + return RegionNotificationEndpointsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionNotificationEndpointsSettings bean configured to use a + * DefaultCredentialsProvider and the client library's default transport channel provider + * (defaultRegionNotificationEndpointsTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionNotificationEndpointsSpringProperties. Method-level properties will take precedence + * over service-level properties if available, and client library defaults will be used if neither + * are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionNotificationEndpointsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionNotificationEndpointsSettings regionNotificationEndpointsSettings( + @Qualifier("defaultRegionNotificationEndpointsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionNotificationEndpointsSettings.Builder clientSettingsBuilder = + RegionNotificationEndpointsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionNotificationEndpointsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionNotificationEndpointsClient bean configured with + * RegionNotificationEndpointsSettings. + * + * @param regionNotificationEndpointsSettings settings to configure an instance of client bean. + * @return a {@link RegionNotificationEndpointsClient} bean configured with {@link + * RegionNotificationEndpointsSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionNotificationEndpointsClient regionNotificationEndpointsClient( + RegionNotificationEndpointsSettings regionNotificationEndpointsSettings) throws IOException { + return RegionNotificationEndpointsClient.create(regionNotificationEndpointsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-notification-endpoints"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNotificationEndpointsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNotificationEndpointsSpringProperties.java new file mode 100644 index 0000000000..c5de6be270 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionNotificationEndpointsSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionNotificationEndpoints client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-notification-endpoints") +public class RegionNotificationEndpointsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionOperationsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionOperationsSpringAutoConfiguration.java new file mode 100644 index 0000000000..3b0c5741c3 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionOperationsSpringAutoConfiguration.java @@ -0,0 +1,237 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionOperationsClient; +import com.google.cloud.compute.v1.RegionOperationsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionOperationsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionOperationsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-operations.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionOperationsSpringProperties.class) +public class RegionOperationsSpringAutoConfiguration { + private final RegionOperationsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionOperationsSpringAutoConfiguration.class); + + protected RegionOperationsSpringAutoConfiguration( + RegionOperationsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionOperations-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionOperationsTransportChannelProvider") + public TransportChannelProvider defaultRegionOperationsTransportChannelProvider() { + return RegionOperationsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionOperationsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultRegionOperationsTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionOperationsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionOperationsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionOperationsSettings regionOperationsSettings( + @Qualifier("defaultRegionOperationsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionOperationsSettings.Builder clientSettingsBuilder = RegionOperationsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionOperationsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings deleteRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.deleteSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.deleteSettings().setRetrySettings(deleteRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings waitRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.waitSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.waitSettings().setRetrySettings(waitRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry deleteRetry = clientProperties.getDeleteRetry(); + if (deleteRetry != null) { + RetrySettings deleteRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.deleteSettings().getRetrySettings(), deleteRetry); + clientSettingsBuilder.deleteSettings().setRetrySettings(deleteRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for delete from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry waitRetry = clientProperties.getWaitRetry(); + if (waitRetry != null) { + RetrySettings waitRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.waitSettings().getRetrySettings(), waitRetry); + clientSettingsBuilder.waitSettings().setRetrySettings(waitRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for wait from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionOperationsClient bean configured with RegionOperationsSettings. + * + * @param regionOperationsSettings settings to configure an instance of client bean. + * @return a {@link RegionOperationsClient} bean configured with {@link RegionOperationsSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionOperationsClient regionOperationsClient( + RegionOperationsSettings regionOperationsSettings) throws IOException { + return RegionOperationsClient.create(regionOperationsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-operations"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionOperationsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionOperationsSpringProperties.java new file mode 100644 index 0000000000..66ebe969ef --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionOperationsSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionOperations client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-operations") +public class RegionOperationsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for delete. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry deleteRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for wait. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry waitRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getDeleteRetry() { + return this.deleteRetry; + } + + public void setDeleteRetry(Retry deleteRetry) { + this.deleteRetry = deleteRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getWaitRetry() { + return this.waitRetry; + } + + public void setWaitRetry(Retry waitRetry) { + this.waitRetry = waitRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSecurityPoliciesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSecurityPoliciesSpringAutoConfiguration.java new file mode 100644 index 0000000000..639007eee2 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSecurityPoliciesSpringAutoConfiguration.java @@ -0,0 +1,210 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionSecurityPoliciesClient; +import com.google.cloud.compute.v1.RegionSecurityPoliciesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionSecurityPoliciesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionSecurityPoliciesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-security-policies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionSecurityPoliciesSpringProperties.class) +public class RegionSecurityPoliciesSpringAutoConfiguration { + private final RegionSecurityPoliciesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionSecurityPoliciesSpringAutoConfiguration.class); + + protected RegionSecurityPoliciesSpringAutoConfiguration( + RegionSecurityPoliciesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionSecurityPolicies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionSecurityPoliciesTransportChannelProvider") + public TransportChannelProvider defaultRegionSecurityPoliciesTransportChannelProvider() { + return RegionSecurityPoliciesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionSecurityPoliciesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultRegionSecurityPoliciesTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionSecurityPoliciesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionSecurityPoliciesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionSecurityPoliciesSettings regionSecurityPoliciesSettings( + @Qualifier("defaultRegionSecurityPoliciesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionSecurityPoliciesSettings.Builder clientSettingsBuilder = + RegionSecurityPoliciesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionSecurityPoliciesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionSecurityPoliciesClient bean configured with RegionSecurityPoliciesSettings. + * + * @param regionSecurityPoliciesSettings settings to configure an instance of client bean. + * @return a {@link RegionSecurityPoliciesClient} bean configured with {@link + * RegionSecurityPoliciesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionSecurityPoliciesClient regionSecurityPoliciesClient( + RegionSecurityPoliciesSettings regionSecurityPoliciesSettings) throws IOException { + return RegionSecurityPoliciesClient.create(regionSecurityPoliciesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-security-policies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSecurityPoliciesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSecurityPoliciesSpringProperties.java new file mode 100644 index 0000000000..cb82aba775 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSecurityPoliciesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionSecurityPolicies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-security-policies") +public class RegionSecurityPoliciesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslCertificatesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslCertificatesSpringAutoConfiguration.java new file mode 100644 index 0000000000..82f5f443fd --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslCertificatesSpringAutoConfiguration.java @@ -0,0 +1,210 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionSslCertificatesClient; +import com.google.cloud.compute.v1.RegionSslCertificatesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionSslCertificatesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionSslCertificatesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-ssl-certificates.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionSslCertificatesSpringProperties.class) +public class RegionSslCertificatesSpringAutoConfiguration { + private final RegionSslCertificatesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionSslCertificatesSpringAutoConfiguration.class); + + protected RegionSslCertificatesSpringAutoConfiguration( + RegionSslCertificatesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionSslCertificates-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionSslCertificatesTransportChannelProvider") + public TransportChannelProvider defaultRegionSslCertificatesTransportChannelProvider() { + return RegionSslCertificatesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionSslCertificatesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultRegionSslCertificatesTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionSslCertificatesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionSslCertificatesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionSslCertificatesSettings regionSslCertificatesSettings( + @Qualifier("defaultRegionSslCertificatesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionSslCertificatesSettings.Builder clientSettingsBuilder = + RegionSslCertificatesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionSslCertificatesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionSslCertificatesClient bean configured with RegionSslCertificatesSettings. + * + * @param regionSslCertificatesSettings settings to configure an instance of client bean. + * @return a {@link RegionSslCertificatesClient} bean configured with {@link + * RegionSslCertificatesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionSslCertificatesClient regionSslCertificatesClient( + RegionSslCertificatesSettings regionSslCertificatesSettings) throws IOException { + return RegionSslCertificatesClient.create(regionSslCertificatesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-ssl-certificates"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslCertificatesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslCertificatesSpringProperties.java new file mode 100644 index 0000000000..db146d6f82 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslCertificatesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionSslCertificates client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-ssl-certificates") +public class RegionSslCertificatesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslPoliciesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslPoliciesSpringAutoConfiguration.java new file mode 100644 index 0000000000..5e8f6e5c8d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslPoliciesSpringAutoConfiguration.java @@ -0,0 +1,231 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionSslPoliciesClient; +import com.google.cloud.compute.v1.RegionSslPoliciesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionSslPoliciesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionSslPoliciesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-ssl-policies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionSslPoliciesSpringProperties.class) +public class RegionSslPoliciesSpringAutoConfiguration { + private final RegionSslPoliciesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionSslPoliciesSpringAutoConfiguration.class); + + protected RegionSslPoliciesSpringAutoConfiguration( + RegionSslPoliciesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionSslPolicies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionSslPoliciesTransportChannelProvider") + public TransportChannelProvider defaultRegionSslPoliciesTransportChannelProvider() { + return RegionSslPoliciesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionSslPoliciesSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultRegionSslPoliciesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionSslPoliciesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionSslPoliciesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionSslPoliciesSettings regionSslPoliciesSettings( + @Qualifier("defaultRegionSslPoliciesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionSslPoliciesSettings.Builder clientSettingsBuilder = + RegionSslPoliciesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionSslPoliciesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listAvailableFeaturesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listAvailableFeaturesSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listAvailableFeaturesSettings() + .setRetrySettings(listAvailableFeaturesRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listAvailableFeaturesRetry = clientProperties.getListAvailableFeaturesRetry(); + if (listAvailableFeaturesRetry != null) { + RetrySettings listAvailableFeaturesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listAvailableFeaturesSettings().getRetrySettings(), + listAvailableFeaturesRetry); + clientSettingsBuilder + .listAvailableFeaturesSettings() + .setRetrySettings(listAvailableFeaturesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listAvailableFeatures from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionSslPoliciesClient bean configured with RegionSslPoliciesSettings. + * + * @param regionSslPoliciesSettings settings to configure an instance of client bean. + * @return a {@link RegionSslPoliciesClient} bean configured with {@link + * RegionSslPoliciesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionSslPoliciesClient regionSslPoliciesClient( + RegionSslPoliciesSettings regionSslPoliciesSettings) throws IOException { + return RegionSslPoliciesClient.create(regionSslPoliciesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-ssl-policies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslPoliciesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslPoliciesSpringProperties.java new file mode 100644 index 0000000000..b75ac48c00 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionSslPoliciesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionSslPolicies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-ssl-policies") +public class RegionSslPoliciesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listAvailableFeatures. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listAvailableFeaturesRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListAvailableFeaturesRetry() { + return this.listAvailableFeaturesRetry; + } + + public void setListAvailableFeaturesRetry(Retry listAvailableFeaturesRetry) { + this.listAvailableFeaturesRetry = listAvailableFeaturesRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpProxiesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpProxiesSpringAutoConfiguration.java new file mode 100644 index 0000000000..dad7b4adea --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpProxiesSpringAutoConfiguration.java @@ -0,0 +1,210 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionTargetHttpProxiesClient; +import com.google.cloud.compute.v1.RegionTargetHttpProxiesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionTargetHttpProxiesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionTargetHttpProxiesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-target-http-proxies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionTargetHttpProxiesSpringProperties.class) +public class RegionTargetHttpProxiesSpringAutoConfiguration { + private final RegionTargetHttpProxiesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionTargetHttpProxiesSpringAutoConfiguration.class); + + protected RegionTargetHttpProxiesSpringAutoConfiguration( + RegionTargetHttpProxiesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionTargetHttpProxies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionTargetHttpProxiesTransportChannelProvider") + public TransportChannelProvider defaultRegionTargetHttpProxiesTransportChannelProvider() { + return RegionTargetHttpProxiesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionTargetHttpProxiesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultRegionTargetHttpProxiesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionTargetHttpProxiesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionTargetHttpProxiesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionTargetHttpProxiesSettings regionTargetHttpProxiesSettings( + @Qualifier("defaultRegionTargetHttpProxiesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionTargetHttpProxiesSettings.Builder clientSettingsBuilder = + RegionTargetHttpProxiesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionTargetHttpProxiesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionTargetHttpProxiesClient bean configured with RegionTargetHttpProxiesSettings. + * + * @param regionTargetHttpProxiesSettings settings to configure an instance of client bean. + * @return a {@link RegionTargetHttpProxiesClient} bean configured with {@link + * RegionTargetHttpProxiesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionTargetHttpProxiesClient regionTargetHttpProxiesClient( + RegionTargetHttpProxiesSettings regionTargetHttpProxiesSettings) throws IOException { + return RegionTargetHttpProxiesClient.create(regionTargetHttpProxiesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-target-http-proxies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpProxiesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpProxiesSpringProperties.java new file mode 100644 index 0000000000..5580eac3a7 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpProxiesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionTargetHttpProxies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-target-http-proxies") +public class RegionTargetHttpProxiesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpsProxiesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpsProxiesSpringAutoConfiguration.java new file mode 100644 index 0000000000..84fdde85f3 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpsProxiesSpringAutoConfiguration.java @@ -0,0 +1,211 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionTargetHttpsProxiesClient; +import com.google.cloud.compute.v1.RegionTargetHttpsProxiesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionTargetHttpsProxiesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionTargetHttpsProxiesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-target-https-proxies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionTargetHttpsProxiesSpringProperties.class) +public class RegionTargetHttpsProxiesSpringAutoConfiguration { + private final RegionTargetHttpsProxiesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionTargetHttpsProxiesSpringAutoConfiguration.class); + + protected RegionTargetHttpsProxiesSpringAutoConfiguration( + RegionTargetHttpsProxiesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionTargetHttpsProxies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionTargetHttpsProxiesTransportChannelProvider") + public TransportChannelProvider defaultRegionTargetHttpsProxiesTransportChannelProvider() { + return RegionTargetHttpsProxiesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionTargetHttpsProxiesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultRegionTargetHttpsProxiesTransportChannelProvider()). It also configures the quota + * project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionTargetHttpsProxiesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionTargetHttpsProxiesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionTargetHttpsProxiesSettings regionTargetHttpsProxiesSettings( + @Qualifier("defaultRegionTargetHttpsProxiesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionTargetHttpsProxiesSettings.Builder clientSettingsBuilder = + RegionTargetHttpsProxiesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionTargetHttpsProxiesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionTargetHttpsProxiesClient bean configured with + * RegionTargetHttpsProxiesSettings. + * + * @param regionTargetHttpsProxiesSettings settings to configure an instance of client bean. + * @return a {@link RegionTargetHttpsProxiesClient} bean configured with {@link + * RegionTargetHttpsProxiesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionTargetHttpsProxiesClient regionTargetHttpsProxiesClient( + RegionTargetHttpsProxiesSettings regionTargetHttpsProxiesSettings) throws IOException { + return RegionTargetHttpsProxiesClient.create(regionTargetHttpsProxiesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-target-https-proxies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpsProxiesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpsProxiesSpringProperties.java new file mode 100644 index 0000000000..487fbec720 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetHttpsProxiesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionTargetHttpsProxies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-target-https-proxies") +public class RegionTargetHttpsProxiesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetTcpProxiesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetTcpProxiesSpringAutoConfiguration.java new file mode 100644 index 0000000000..8171c3be70 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetTcpProxiesSpringAutoConfiguration.java @@ -0,0 +1,210 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionTargetTcpProxiesClient; +import com.google.cloud.compute.v1.RegionTargetTcpProxiesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionTargetTcpProxiesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionTargetTcpProxiesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-target-tcp-proxies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionTargetTcpProxiesSpringProperties.class) +public class RegionTargetTcpProxiesSpringAutoConfiguration { + private final RegionTargetTcpProxiesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(RegionTargetTcpProxiesSpringAutoConfiguration.class); + + protected RegionTargetTcpProxiesSpringAutoConfiguration( + RegionTargetTcpProxiesSpringProperties clientProperties, + CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionTargetTcpProxies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionTargetTcpProxiesTransportChannelProvider") + public TransportChannelProvider defaultRegionTargetTcpProxiesTransportChannelProvider() { + return RegionTargetTcpProxiesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionTargetTcpProxiesSettings bean configured to use a DefaultCredentialsProvider + * and the client library's default transport channel provider + * (defaultRegionTargetTcpProxiesTransportChannelProvider()). It also configures the quota project + * ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionTargetTcpProxiesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionTargetTcpProxiesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionTargetTcpProxiesSettings regionTargetTcpProxiesSettings( + @Qualifier("defaultRegionTargetTcpProxiesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionTargetTcpProxiesSettings.Builder clientSettingsBuilder = + RegionTargetTcpProxiesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionTargetTcpProxiesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionTargetTcpProxiesClient bean configured with RegionTargetTcpProxiesSettings. + * + * @param regionTargetTcpProxiesSettings settings to configure an instance of client bean. + * @return a {@link RegionTargetTcpProxiesClient} bean configured with {@link + * RegionTargetTcpProxiesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionTargetTcpProxiesClient regionTargetTcpProxiesClient( + RegionTargetTcpProxiesSettings regionTargetTcpProxiesSettings) throws IOException { + return RegionTargetTcpProxiesClient.create(regionTargetTcpProxiesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-target-tcp-proxies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetTcpProxiesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetTcpProxiesSpringProperties.java new file mode 100644 index 0000000000..22dc000425 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionTargetTcpProxiesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionTargetTcpProxies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-target-tcp-proxies") +public class RegionTargetTcpProxiesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionUrlMapsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionUrlMapsSpringAutoConfiguration.java new file mode 100644 index 0000000000..2ac39bcad5 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionUrlMapsSpringAutoConfiguration.java @@ -0,0 +1,221 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionUrlMapsClient; +import com.google.cloud.compute.v1.RegionUrlMapsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionUrlMapsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionUrlMapsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.region-url-maps.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(RegionUrlMapsSpringProperties.class) +public class RegionUrlMapsSpringAutoConfiguration { + private final RegionUrlMapsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(RegionUrlMapsSpringAutoConfiguration.class); + + protected RegionUrlMapsSpringAutoConfiguration( + RegionUrlMapsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from RegionUrlMaps-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionUrlMapsTransportChannelProvider") + public TransportChannelProvider defaultRegionUrlMapsTransportChannelProvider() { + return RegionUrlMapsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionUrlMapsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultRegionUrlMapsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionUrlMapsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionUrlMapsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionUrlMapsSettings regionUrlMapsSettings( + @Qualifier("defaultRegionUrlMapsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionUrlMapsSettings.Builder clientSettingsBuilder = RegionUrlMapsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionUrlMapsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings validateRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.validateSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.validateSettings().setRetrySettings(validateRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry validateRetry = clientProperties.getValidateRetry(); + if (validateRetry != null) { + RetrySettings validateRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.validateSettings().getRetrySettings(), validateRetry); + clientSettingsBuilder.validateSettings().setRetrySettings(validateRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for validate from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionUrlMapsClient bean configured with RegionUrlMapsSettings. + * + * @param regionUrlMapsSettings settings to configure an instance of client bean. + * @return a {@link RegionUrlMapsClient} bean configured with {@link RegionUrlMapsSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionUrlMapsClient regionUrlMapsClient(RegionUrlMapsSettings regionUrlMapsSettings) + throws IOException { + return RegionUrlMapsClient.create(regionUrlMapsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-region-url-maps"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionUrlMapsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionUrlMapsSpringProperties.java new file mode 100644 index 0000000000..0e449a9ba4 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionUrlMapsSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for RegionUrlMaps client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.region-url-maps") +public class RegionUrlMapsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for validate. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry validateRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getValidateRetry() { + return this.validateRetry; + } + + public void setValidateRetry(Retry validateRetry) { + this.validateRetry = validateRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionsSpringAutoConfiguration.java new file mode 100644 index 0000000000..2dd321a0ad --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionsSpringAutoConfiguration.java @@ -0,0 +1,200 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RegionsClient; +import com.google.cloud.compute.v1.RegionsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RegionsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RegionsClient.class) +@ConditionalOnProperty(value = "com.google.cloud.compute.v1.regions.enabled", matchIfMissing = true) +@EnableConfigurationProperties(RegionsSpringProperties.class) +public class RegionsSpringAutoConfiguration { + private final RegionsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(RegionsSpringAutoConfiguration.class); + + protected RegionsSpringAutoConfiguration( + RegionsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Regions-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRegionsTransportChannelProvider") + public TransportChannelProvider defaultRegionsTransportChannelProvider() { + return RegionsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RegionsSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultRegionsTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RegionsSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RegionsSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RegionsSettings regionsSettings( + @Qualifier("defaultRegionsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RegionsSettings.Builder clientSettingsBuilder = RegionsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RegionsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RegionsClient bean configured with RegionsSettings. + * + * @param regionsSettings settings to configure an instance of client bean. + * @return a {@link RegionsClient} bean configured with {@link RegionsSettings} + */ + @Bean + @ConditionalOnMissingBean + public RegionsClient regionsClient(RegionsSettings regionsSettings) throws IOException { + return RegionsClient.create(regionsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-regions"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionsSpringProperties.java new file mode 100644 index 0000000000..331770bc95 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RegionsSpringProperties.java @@ -0,0 +1,101 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Regions client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.regions") +public class RegionsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ReservationsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ReservationsSpringAutoConfiguration.java new file mode 100644 index 0000000000..2eeb2a1eb2 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ReservationsSpringAutoConfiguration.java @@ -0,0 +1,273 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ReservationsClient; +import com.google.cloud.compute.v1.ReservationsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ReservationsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ReservationsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.reservations.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(ReservationsSpringProperties.class) +public class ReservationsSpringAutoConfiguration { + private final ReservationsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(ReservationsSpringAutoConfiguration.class); + + protected ReservationsSpringAutoConfiguration( + ReservationsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Reservations-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultReservationsTransportChannelProvider") + public TransportChannelProvider defaultReservationsTransportChannelProvider() { + return ReservationsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ReservationsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultReservationsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ReservationsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ReservationsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public ReservationsSettings reservationsSettings( + @Qualifier("defaultReservationsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ReservationsSettings.Builder clientSettingsBuilder = ReservationsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ReservationsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ReservationsClient bean configured with ReservationsSettings. + * + * @param reservationsSettings settings to configure an instance of client bean. + * @return a {@link ReservationsClient} bean configured with {@link ReservationsSettings} + */ + @Bean + @ConditionalOnMissingBean + public ReservationsClient reservationsClient(ReservationsSettings reservationsSettings) + throws IOException { + return ReservationsClient.create(reservationsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-reservations"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ReservationsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ReservationsSpringProperties.java new file mode 100644 index 0000000000..fcadbcfd43 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ReservationsSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Reservations client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.reservations") +public class ReservationsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ResourcePoliciesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ResourcePoliciesSpringAutoConfiguration.java new file mode 100644 index 0000000000..bf29ee0af4 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ResourcePoliciesSpringAutoConfiguration.java @@ -0,0 +1,274 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ResourcePoliciesClient; +import com.google.cloud.compute.v1.ResourcePoliciesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ResourcePoliciesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ResourcePoliciesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.resource-policies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(ResourcePoliciesSpringProperties.class) +public class ResourcePoliciesSpringAutoConfiguration { + private final ResourcePoliciesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(ResourcePoliciesSpringAutoConfiguration.class); + + protected ResourcePoliciesSpringAutoConfiguration( + ResourcePoliciesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from ResourcePolicies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultResourcePoliciesTransportChannelProvider") + public TransportChannelProvider defaultResourcePoliciesTransportChannelProvider() { + return ResourcePoliciesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ResourcePoliciesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultResourcePoliciesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ResourcePoliciesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ResourcePoliciesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public ResourcePoliciesSettings resourcePoliciesSettings( + @Qualifier("defaultResourcePoliciesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ResourcePoliciesSettings.Builder clientSettingsBuilder = ResourcePoliciesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ResourcePoliciesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ResourcePoliciesClient bean configured with ResourcePoliciesSettings. + * + * @param resourcePoliciesSettings settings to configure an instance of client bean. + * @return a {@link ResourcePoliciesClient} bean configured with {@link ResourcePoliciesSettings} + */ + @Bean + @ConditionalOnMissingBean + public ResourcePoliciesClient resourcePoliciesClient( + ResourcePoliciesSettings resourcePoliciesSettings) throws IOException { + return ResourcePoliciesClient.create(resourcePoliciesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-resource-policies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ResourcePoliciesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ResourcePoliciesSpringProperties.java new file mode 100644 index 0000000000..8ab284c65b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ResourcePoliciesSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for ResourcePolicies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.resource-policies") +public class ResourcePoliciesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutersSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutersSpringAutoConfiguration.java new file mode 100644 index 0000000000..15bf405cfd --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutersSpringAutoConfiguration.java @@ -0,0 +1,272 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RoutersClient; +import com.google.cloud.compute.v1.RoutersSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RoutersClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RoutersClient.class) +@ConditionalOnProperty(value = "com.google.cloud.compute.v1.routers.enabled", matchIfMissing = true) +@EnableConfigurationProperties(RoutersSpringProperties.class) +public class RoutersSpringAutoConfiguration { + private final RoutersSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(RoutersSpringAutoConfiguration.class); + + protected RoutersSpringAutoConfiguration( + RoutersSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Routers-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRoutersTransportChannelProvider") + public TransportChannelProvider defaultRoutersTransportChannelProvider() { + return RoutersSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RoutersSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultRoutersTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RoutersSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RoutersSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RoutersSettings routersSettings( + @Qualifier("defaultRoutersTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RoutersSettings.Builder clientSettingsBuilder = RoutersSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RoutersSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getNatMappingInfoRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getNatMappingInfoSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .getNatMappingInfoSettings() + .setRetrySettings(getNatMappingInfoRetrySettings); + + RetrySettings getRouterStatusRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRouterStatusSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .getRouterStatusSettings() + .setRetrySettings(getRouterStatusRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings previewRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.previewSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.previewSettings().setRetrySettings(previewRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getNatMappingInfoRetry = clientProperties.getGetNatMappingInfoRetry(); + if (getNatMappingInfoRetry != null) { + RetrySettings getNatMappingInfoRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getNatMappingInfoSettings().getRetrySettings(), + getNatMappingInfoRetry); + clientSettingsBuilder + .getNatMappingInfoSettings() + .setRetrySettings(getNatMappingInfoRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for getNatMappingInfo from properties."); + } + } + Retry getRouterStatusRetry = clientProperties.getGetRouterStatusRetry(); + if (getRouterStatusRetry != null) { + RetrySettings getRouterStatusRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRouterStatusSettings().getRetrySettings(), + getRouterStatusRetry); + clientSettingsBuilder + .getRouterStatusSettings() + .setRetrySettings(getRouterStatusRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getRouterStatus from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry previewRetry = clientProperties.getPreviewRetry(); + if (previewRetry != null) { + RetrySettings previewRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.previewSettings().getRetrySettings(), previewRetry); + clientSettingsBuilder.previewSettings().setRetrySettings(previewRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for preview from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RoutersClient bean configured with RoutersSettings. + * + * @param routersSettings settings to configure an instance of client bean. + * @return a {@link RoutersClient} bean configured with {@link RoutersSettings} + */ + @Bean + @ConditionalOnMissingBean + public RoutersClient routersClient(RoutersSettings routersSettings) throws IOException { + return RoutersClient.create(routersSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-routers"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutersSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutersSpringProperties.java new file mode 100644 index 0000000000..1e95d10708 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutersSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Routers client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.routers") +public class RoutersSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getNatMappingInfo. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getNatMappingInfoRetry; + /** + * Allow override of retry settings at method-level for getRouterStatus. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRouterStatusRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for preview. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry previewRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetNatMappingInfoRetry() { + return this.getNatMappingInfoRetry; + } + + public void setGetNatMappingInfoRetry(Retry getNatMappingInfoRetry) { + this.getNatMappingInfoRetry = getNatMappingInfoRetry; + } + + public Retry getGetRouterStatusRetry() { + return this.getRouterStatusRetry; + } + + public void setGetRouterStatusRetry(Retry getRouterStatusRetry) { + this.getRouterStatusRetry = getRouterStatusRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getPreviewRetry() { + return this.previewRetry; + } + + public void setPreviewRetry(Retry previewRetry) { + this.previewRetry = previewRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutesSpringAutoConfiguration.java new file mode 100644 index 0000000000..622569b37f --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutesSpringAutoConfiguration.java @@ -0,0 +1,200 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.RoutesClient; +import com.google.cloud.compute.v1.RoutesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link RoutesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(RoutesClient.class) +@ConditionalOnProperty(value = "com.google.cloud.compute.v1.routes.enabled", matchIfMissing = true) +@EnableConfigurationProperties(RoutesSpringProperties.class) +public class RoutesSpringAutoConfiguration { + private final RoutesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(RoutesSpringAutoConfiguration.class); + + protected RoutesSpringAutoConfiguration( + RoutesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Routes-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultRoutesTransportChannelProvider") + public TransportChannelProvider defaultRoutesTransportChannelProvider() { + return RoutesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a RoutesSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultRoutesTransportChannelProvider()). It also + * configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in RoutesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link RoutesSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public RoutesSettings routesSettings( + @Qualifier("defaultRoutesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + RoutesSettings.Builder clientSettingsBuilder = RoutesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + RoutesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a RoutesClient bean configured with RoutesSettings. + * + * @param routesSettings settings to configure an instance of client bean. + * @return a {@link RoutesClient} bean configured with {@link RoutesSettings} + */ + @Bean + @ConditionalOnMissingBean + public RoutesClient routesClient(RoutesSettings routesSettings) throws IOException { + return RoutesClient.create(routesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-routes"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutesSpringProperties.java new file mode 100644 index 0000000000..4640603ffa --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/RoutesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Routes client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.routes") +public class RoutesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SecurityPoliciesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SecurityPoliciesSpringAutoConfiguration.java new file mode 100644 index 0000000000..f9c441283b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SecurityPoliciesSpringAutoConfiguration.java @@ -0,0 +1,261 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.SecurityPoliciesClient; +import com.google.cloud.compute.v1.SecurityPoliciesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link SecurityPoliciesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(SecurityPoliciesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.security-policies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(SecurityPoliciesSpringProperties.class) +public class SecurityPoliciesSpringAutoConfiguration { + private final SecurityPoliciesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(SecurityPoliciesSpringAutoConfiguration.class); + + protected SecurityPoliciesSpringAutoConfiguration( + SecurityPoliciesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from SecurityPolicies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultSecurityPoliciesTransportChannelProvider") + public TransportChannelProvider defaultSecurityPoliciesTransportChannelProvider() { + return SecurityPoliciesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a SecurityPoliciesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultSecurityPoliciesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in SecurityPoliciesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link SecurityPoliciesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public SecurityPoliciesSettings securityPoliciesSettings( + @Qualifier("defaultSecurityPoliciesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + SecurityPoliciesSettings.Builder clientSettingsBuilder = SecurityPoliciesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + SecurityPoliciesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getRuleRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRuleSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getRuleSettings().setRetrySettings(getRuleRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listPreconfiguredExpressionSetsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listPreconfiguredExpressionSetsSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listPreconfiguredExpressionSetsSettings() + .setRetrySettings(listPreconfiguredExpressionSetsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getRuleRetry = clientProperties.getGetRuleRetry(); + if (getRuleRetry != null) { + RetrySettings getRuleRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getRuleSettings().getRetrySettings(), getRuleRetry); + clientSettingsBuilder.getRuleSettings().setRetrySettings(getRuleRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getRule from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listPreconfiguredExpressionSetsRetry = + clientProperties.getListPreconfiguredExpressionSetsRetry(); + if (listPreconfiguredExpressionSetsRetry != null) { + RetrySettings listPreconfiguredExpressionSetsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listPreconfiguredExpressionSetsSettings().getRetrySettings(), + listPreconfiguredExpressionSetsRetry); + clientSettingsBuilder + .listPreconfiguredExpressionSetsSettings() + .setRetrySettings(listPreconfiguredExpressionSetsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listPreconfiguredExpressionSets from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a SecurityPoliciesClient bean configured with SecurityPoliciesSettings. + * + * @param securityPoliciesSettings settings to configure an instance of client bean. + * @return a {@link SecurityPoliciesClient} bean configured with {@link SecurityPoliciesSettings} + */ + @Bean + @ConditionalOnMissingBean + public SecurityPoliciesClient securityPoliciesClient( + SecurityPoliciesSettings securityPoliciesSettings) throws IOException { + return SecurityPoliciesClient.create(securityPoliciesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-security-policies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SecurityPoliciesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SecurityPoliciesSpringProperties.java new file mode 100644 index 0000000000..bba93f0178 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SecurityPoliciesSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for SecurityPolicies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.security-policies") +public class SecurityPoliciesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getRule. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRuleRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listPreconfiguredExpressionSets. If + * defined, this takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listPreconfiguredExpressionSetsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetRuleRetry() { + return this.getRuleRetry; + } + + public void setGetRuleRetry(Retry getRuleRetry) { + this.getRuleRetry = getRuleRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListPreconfiguredExpressionSetsRetry() { + return this.listPreconfiguredExpressionSetsRetry; + } + + public void setListPreconfiguredExpressionSetsRetry(Retry listPreconfiguredExpressionSetsRetry) { + this.listPreconfiguredExpressionSetsRetry = listPreconfiguredExpressionSetsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ServiceAttachmentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ServiceAttachmentsSpringAutoConfiguration.java new file mode 100644 index 0000000000..7a96ea098b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ServiceAttachmentsSpringAutoConfiguration.java @@ -0,0 +1,276 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ServiceAttachmentsClient; +import com.google.cloud.compute.v1.ServiceAttachmentsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ServiceAttachmentsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ServiceAttachmentsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.service-attachments.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(ServiceAttachmentsSpringProperties.class) +public class ServiceAttachmentsSpringAutoConfiguration { + private final ServiceAttachmentsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(ServiceAttachmentsSpringAutoConfiguration.class); + + protected ServiceAttachmentsSpringAutoConfiguration( + ServiceAttachmentsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from ServiceAttachments-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultServiceAttachmentsTransportChannelProvider") + public TransportChannelProvider defaultServiceAttachmentsTransportChannelProvider() { + return ServiceAttachmentsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ServiceAttachmentsSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultServiceAttachmentsTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ServiceAttachmentsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ServiceAttachmentsSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public ServiceAttachmentsSettings serviceAttachmentsSettings( + @Qualifier("defaultServiceAttachmentsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ServiceAttachmentsSettings.Builder clientSettingsBuilder = + ServiceAttachmentsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ServiceAttachmentsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ServiceAttachmentsClient bean configured with ServiceAttachmentsSettings. + * + * @param serviceAttachmentsSettings settings to configure an instance of client bean. + * @return a {@link ServiceAttachmentsClient} bean configured with {@link + * ServiceAttachmentsSettings} + */ + @Bean + @ConditionalOnMissingBean + public ServiceAttachmentsClient serviceAttachmentsClient( + ServiceAttachmentsSettings serviceAttachmentsSettings) throws IOException { + return ServiceAttachmentsClient.create(serviceAttachmentsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-service-attachments"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ServiceAttachmentsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ServiceAttachmentsSpringProperties.java new file mode 100644 index 0000000000..e11dec6ac9 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ServiceAttachmentsSpringProperties.java @@ -0,0 +1,152 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for ServiceAttachments client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.service-attachments") +public class ServiceAttachmentsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SnapshotsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SnapshotsSpringAutoConfiguration.java new file mode 100644 index 0000000000..a2f23b7f4d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SnapshotsSpringAutoConfiguration.java @@ -0,0 +1,253 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.SnapshotsClient; +import com.google.cloud.compute.v1.SnapshotsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link SnapshotsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(SnapshotsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.snapshots.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(SnapshotsSpringProperties.class) +public class SnapshotsSpringAutoConfiguration { + private final SnapshotsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(SnapshotsSpringAutoConfiguration.class); + + protected SnapshotsSpringAutoConfiguration( + SnapshotsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Snapshots-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultSnapshotsTransportChannelProvider") + public TransportChannelProvider defaultSnapshotsTransportChannelProvider() { + return SnapshotsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a SnapshotsSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultSnapshotsTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in SnapshotsSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link SnapshotsSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public SnapshotsSettings snapshotsSettings( + @Qualifier("defaultSnapshotsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + SnapshotsSettings.Builder clientSettingsBuilder = SnapshotsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + SnapshotsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a SnapshotsClient bean configured with SnapshotsSettings. + * + * @param snapshotsSettings settings to configure an instance of client bean. + * @return a {@link SnapshotsClient} bean configured with {@link SnapshotsSettings} + */ + @Bean + @ConditionalOnMissingBean + public SnapshotsClient snapshotsClient(SnapshotsSettings snapshotsSettings) throws IOException { + return SnapshotsClient.create(snapshotsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-snapshots"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SnapshotsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SnapshotsSpringProperties.java new file mode 100644 index 0000000000..5ac5442c86 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SnapshotsSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Snapshots client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.snapshots") +public class SnapshotsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslCertificatesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslCertificatesSpringAutoConfiguration.java new file mode 100644 index 0000000000..2e18daca9a --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslCertificatesSpringAutoConfiguration.java @@ -0,0 +1,222 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.SslCertificatesClient; +import com.google.cloud.compute.v1.SslCertificatesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link SslCertificatesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(SslCertificatesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.ssl-certificates.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(SslCertificatesSpringProperties.class) +public class SslCertificatesSpringAutoConfiguration { + private final SslCertificatesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(SslCertificatesSpringAutoConfiguration.class); + + protected SslCertificatesSpringAutoConfiguration( + SslCertificatesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from SslCertificates-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultSslCertificatesTransportChannelProvider") + public TransportChannelProvider defaultSslCertificatesTransportChannelProvider() { + return SslCertificatesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a SslCertificatesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultSslCertificatesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in SslCertificatesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link SslCertificatesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public SslCertificatesSettings sslCertificatesSettings( + @Qualifier("defaultSslCertificatesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + SslCertificatesSettings.Builder clientSettingsBuilder = SslCertificatesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + SslCertificatesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a SslCertificatesClient bean configured with SslCertificatesSettings. + * + * @param sslCertificatesSettings settings to configure an instance of client bean. + * @return a {@link SslCertificatesClient} bean configured with {@link SslCertificatesSettings} + */ + @Bean + @ConditionalOnMissingBean + public SslCertificatesClient sslCertificatesClient( + SslCertificatesSettings sslCertificatesSettings) throws IOException { + return SslCertificatesClient.create(sslCertificatesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-ssl-certificates"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslCertificatesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslCertificatesSpringProperties.java new file mode 100644 index 0000000000..492bd4b418 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslCertificatesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for SslCertificates client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.ssl-certificates") +public class SslCertificatesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslPoliciesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslPoliciesSpringAutoConfiguration.java new file mode 100644 index 0000000000..364805a270 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslPoliciesSpringAutoConfiguration.java @@ -0,0 +1,243 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.SslPoliciesClient; +import com.google.cloud.compute.v1.SslPoliciesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link SslPoliciesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(SslPoliciesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.ssl-policies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(SslPoliciesSpringProperties.class) +public class SslPoliciesSpringAutoConfiguration { + private final SslPoliciesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(SslPoliciesSpringAutoConfiguration.class); + + protected SslPoliciesSpringAutoConfiguration( + SslPoliciesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from SslPolicies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultSslPoliciesTransportChannelProvider") + public TransportChannelProvider defaultSslPoliciesTransportChannelProvider() { + return SslPoliciesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a SslPoliciesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultSslPoliciesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in SslPoliciesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link SslPoliciesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public SslPoliciesSettings sslPoliciesSettings( + @Qualifier("defaultSslPoliciesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + SslPoliciesSettings.Builder clientSettingsBuilder = SslPoliciesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + SslPoliciesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listAvailableFeaturesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listAvailableFeaturesSettings().getRetrySettings(), + serviceRetry); + clientSettingsBuilder + .listAvailableFeaturesSettings() + .setRetrySettings(listAvailableFeaturesRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listAvailableFeaturesRetry = clientProperties.getListAvailableFeaturesRetry(); + if (listAvailableFeaturesRetry != null) { + RetrySettings listAvailableFeaturesRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listAvailableFeaturesSettings().getRetrySettings(), + listAvailableFeaturesRetry); + clientSettingsBuilder + .listAvailableFeaturesSettings() + .setRetrySettings(listAvailableFeaturesRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for listAvailableFeatures from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a SslPoliciesClient bean configured with SslPoliciesSettings. + * + * @param sslPoliciesSettings settings to configure an instance of client bean. + * @return a {@link SslPoliciesClient} bean configured with {@link SslPoliciesSettings} + */ + @Bean + @ConditionalOnMissingBean + public SslPoliciesClient sslPoliciesClient(SslPoliciesSettings sslPoliciesSettings) + throws IOException { + return SslPoliciesClient.create(sslPoliciesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-ssl-policies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslPoliciesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslPoliciesSpringProperties.java new file mode 100644 index 0000000000..7e41a5c1cb --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SslPoliciesSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for SslPolicies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.ssl-policies") +public class SslPoliciesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listAvailableFeatures. If defined, this + * takes precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listAvailableFeaturesRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListAvailableFeaturesRetry() { + return this.listAvailableFeaturesRetry; + } + + public void setListAvailableFeaturesRetry(Retry listAvailableFeaturesRetry) { + this.listAvailableFeaturesRetry = listAvailableFeaturesRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SubnetworksSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SubnetworksSpringAutoConfiguration.java new file mode 100644 index 0000000000..9aba246de8 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SubnetworksSpringAutoConfiguration.java @@ -0,0 +1,287 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.SubnetworksClient; +import com.google.cloud.compute.v1.SubnetworksSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link SubnetworksClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(SubnetworksClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.subnetworks.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(SubnetworksSpringProperties.class) +public class SubnetworksSpringAutoConfiguration { + private final SubnetworksSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(SubnetworksSpringAutoConfiguration.class); + + protected SubnetworksSpringAutoConfiguration( + SubnetworksSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Subnetworks-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultSubnetworksTransportChannelProvider") + public TransportChannelProvider defaultSubnetworksTransportChannelProvider() { + return SubnetworksSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a SubnetworksSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultSubnetworksTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in SubnetworksSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link SubnetworksSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public SubnetworksSettings subnetworksSettings( + @Qualifier("defaultSubnetworksTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + SubnetworksSettings.Builder clientSettingsBuilder = SubnetworksSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + SubnetworksSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings listUsableRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listUsableSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listUsableSettings().setRetrySettings(listUsableRetrySettings); + + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getIamPolicyRetry = clientProperties.getGetIamPolicyRetry(); + if (getIamPolicyRetry != null) { + RetrySettings getIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getIamPolicySettings().getRetrySettings(), getIamPolicyRetry); + clientSettingsBuilder.getIamPolicySettings().setRetrySettings(getIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getIamPolicy from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry listUsableRetry = clientProperties.getListUsableRetry(); + if (listUsableRetry != null) { + RetrySettings listUsableRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listUsableSettings().getRetrySettings(), listUsableRetry); + clientSettingsBuilder.listUsableSettings().setRetrySettings(listUsableRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for listUsable from properties."); + } + } + Retry setIamPolicyRetry = clientProperties.getSetIamPolicyRetry(); + if (setIamPolicyRetry != null) { + RetrySettings setIamPolicyRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.setIamPolicySettings().getRetrySettings(), setIamPolicyRetry); + clientSettingsBuilder.setIamPolicySettings().setRetrySettings(setIamPolicyRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for setIamPolicy from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a SubnetworksClient bean configured with SubnetworksSettings. + * + * @param subnetworksSettings settings to configure an instance of client bean. + * @return a {@link SubnetworksClient} bean configured with {@link SubnetworksSettings} + */ + @Bean + @ConditionalOnMissingBean + public SubnetworksClient subnetworksClient(SubnetworksSettings subnetworksSettings) + throws IOException { + return SubnetworksClient.create(subnetworksSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-subnetworks"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SubnetworksSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SubnetworksSpringProperties.java new file mode 100644 index 0000000000..45bd3962ff --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/SubnetworksSpringProperties.java @@ -0,0 +1,165 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Subnetworks client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.subnetworks") +public class SubnetworksSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getIamPolicyRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for listUsable. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listUsableRetry; + /** + * Allow override of retry settings at method-level for setIamPolicy. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry setIamPolicyRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetIamPolicyRetry() { + return this.getIamPolicyRetry; + } + + public void setGetIamPolicyRetry(Retry getIamPolicyRetry) { + this.getIamPolicyRetry = getIamPolicyRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getListUsableRetry() { + return this.listUsableRetry; + } + + public void setListUsableRetry(Retry listUsableRetry) { + this.listUsableRetry = listUsableRetry; + } + + public Retry getSetIamPolicyRetry() { + return this.setIamPolicyRetry; + } + + public void setSetIamPolicyRetry(Retry setIamPolicyRetry) { + this.setIamPolicyRetry = setIamPolicyRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetGrpcProxiesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetGrpcProxiesSpringAutoConfiguration.java new file mode 100644 index 0000000000..eae8dec137 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetGrpcProxiesSpringAutoConfiguration.java @@ -0,0 +1,209 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.TargetGrpcProxiesClient; +import com.google.cloud.compute.v1.TargetGrpcProxiesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link TargetGrpcProxiesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(TargetGrpcProxiesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.target-grpc-proxies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(TargetGrpcProxiesSpringProperties.class) +public class TargetGrpcProxiesSpringAutoConfiguration { + private final TargetGrpcProxiesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(TargetGrpcProxiesSpringAutoConfiguration.class); + + protected TargetGrpcProxiesSpringAutoConfiguration( + TargetGrpcProxiesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from TargetGrpcProxies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultTargetGrpcProxiesTransportChannelProvider") + public TransportChannelProvider defaultTargetGrpcProxiesTransportChannelProvider() { + return TargetGrpcProxiesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a TargetGrpcProxiesSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultTargetGrpcProxiesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in TargetGrpcProxiesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link TargetGrpcProxiesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public TargetGrpcProxiesSettings targetGrpcProxiesSettings( + @Qualifier("defaultTargetGrpcProxiesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + TargetGrpcProxiesSettings.Builder clientSettingsBuilder = + TargetGrpcProxiesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + TargetGrpcProxiesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a TargetGrpcProxiesClient bean configured with TargetGrpcProxiesSettings. + * + * @param targetGrpcProxiesSettings settings to configure an instance of client bean. + * @return a {@link TargetGrpcProxiesClient} bean configured with {@link + * TargetGrpcProxiesSettings} + */ + @Bean + @ConditionalOnMissingBean + public TargetGrpcProxiesClient targetGrpcProxiesClient( + TargetGrpcProxiesSettings targetGrpcProxiesSettings) throws IOException { + return TargetGrpcProxiesClient.create(targetGrpcProxiesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-target-grpc-proxies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetGrpcProxiesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetGrpcProxiesSpringProperties.java new file mode 100644 index 0000000000..a1e5e4a24b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetGrpcProxiesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for TargetGrpcProxies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.target-grpc-proxies") +public class TargetGrpcProxiesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpProxiesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpProxiesSpringAutoConfiguration.java new file mode 100644 index 0000000000..33351bf4b6 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpProxiesSpringAutoConfiguration.java @@ -0,0 +1,225 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.TargetHttpProxiesClient; +import com.google.cloud.compute.v1.TargetHttpProxiesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link TargetHttpProxiesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(TargetHttpProxiesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.target-http-proxies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(TargetHttpProxiesSpringProperties.class) +public class TargetHttpProxiesSpringAutoConfiguration { + private final TargetHttpProxiesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(TargetHttpProxiesSpringAutoConfiguration.class); + + protected TargetHttpProxiesSpringAutoConfiguration( + TargetHttpProxiesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from TargetHttpProxies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultTargetHttpProxiesTransportChannelProvider") + public TransportChannelProvider defaultTargetHttpProxiesTransportChannelProvider() { + return TargetHttpProxiesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a TargetHttpProxiesSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultTargetHttpProxiesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in TargetHttpProxiesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link TargetHttpProxiesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public TargetHttpProxiesSettings targetHttpProxiesSettings( + @Qualifier("defaultTargetHttpProxiesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + TargetHttpProxiesSettings.Builder clientSettingsBuilder = + TargetHttpProxiesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + TargetHttpProxiesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a TargetHttpProxiesClient bean configured with TargetHttpProxiesSettings. + * + * @param targetHttpProxiesSettings settings to configure an instance of client bean. + * @return a {@link TargetHttpProxiesClient} bean configured with {@link + * TargetHttpProxiesSettings} + */ + @Bean + @ConditionalOnMissingBean + public TargetHttpProxiesClient targetHttpProxiesClient( + TargetHttpProxiesSettings targetHttpProxiesSettings) throws IOException { + return TargetHttpProxiesClient.create(targetHttpProxiesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-target-http-proxies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpProxiesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpProxiesSpringProperties.java new file mode 100644 index 0000000000..9733c274cd --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpProxiesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for TargetHttpProxies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.target-http-proxies") +public class TargetHttpProxiesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpsProxiesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpsProxiesSpringAutoConfiguration.java new file mode 100644 index 0000000000..c7a7097f89 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpsProxiesSpringAutoConfiguration.java @@ -0,0 +1,225 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.TargetHttpsProxiesClient; +import com.google.cloud.compute.v1.TargetHttpsProxiesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link TargetHttpsProxiesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(TargetHttpsProxiesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.target-https-proxies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(TargetHttpsProxiesSpringProperties.class) +public class TargetHttpsProxiesSpringAutoConfiguration { + private final TargetHttpsProxiesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(TargetHttpsProxiesSpringAutoConfiguration.class); + + protected TargetHttpsProxiesSpringAutoConfiguration( + TargetHttpsProxiesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from TargetHttpsProxies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultTargetHttpsProxiesTransportChannelProvider") + public TransportChannelProvider defaultTargetHttpsProxiesTransportChannelProvider() { + return TargetHttpsProxiesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a TargetHttpsProxiesSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultTargetHttpsProxiesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in TargetHttpsProxiesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link TargetHttpsProxiesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public TargetHttpsProxiesSettings targetHttpsProxiesSettings( + @Qualifier("defaultTargetHttpsProxiesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + TargetHttpsProxiesSettings.Builder clientSettingsBuilder = + TargetHttpsProxiesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + TargetHttpsProxiesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a TargetHttpsProxiesClient bean configured with TargetHttpsProxiesSettings. + * + * @param targetHttpsProxiesSettings settings to configure an instance of client bean. + * @return a {@link TargetHttpsProxiesClient} bean configured with {@link + * TargetHttpsProxiesSettings} + */ + @Bean + @ConditionalOnMissingBean + public TargetHttpsProxiesClient targetHttpsProxiesClient( + TargetHttpsProxiesSettings targetHttpsProxiesSettings) throws IOException { + return TargetHttpsProxiesClient.create(targetHttpsProxiesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-target-https-proxies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpsProxiesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpsProxiesSpringProperties.java new file mode 100644 index 0000000000..8719d94754 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetHttpsProxiesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for TargetHttpsProxies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.target-https-proxies") +public class TargetHttpsProxiesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetInstancesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetInstancesSpringAutoConfiguration.java new file mode 100644 index 0000000000..d0130fac20 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetInstancesSpringAutoConfiguration.java @@ -0,0 +1,222 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.TargetInstancesClient; +import com.google.cloud.compute.v1.TargetInstancesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link TargetInstancesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(TargetInstancesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.target-instances.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(TargetInstancesSpringProperties.class) +public class TargetInstancesSpringAutoConfiguration { + private final TargetInstancesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(TargetInstancesSpringAutoConfiguration.class); + + protected TargetInstancesSpringAutoConfiguration( + TargetInstancesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from TargetInstances-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultTargetInstancesTransportChannelProvider") + public TransportChannelProvider defaultTargetInstancesTransportChannelProvider() { + return TargetInstancesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a TargetInstancesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultTargetInstancesTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in TargetInstancesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link TargetInstancesSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public TargetInstancesSettings targetInstancesSettings( + @Qualifier("defaultTargetInstancesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + TargetInstancesSettings.Builder clientSettingsBuilder = TargetInstancesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + TargetInstancesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a TargetInstancesClient bean configured with TargetInstancesSettings. + * + * @param targetInstancesSettings settings to configure an instance of client bean. + * @return a {@link TargetInstancesClient} bean configured with {@link TargetInstancesSettings} + */ + @Bean + @ConditionalOnMissingBean + public TargetInstancesClient targetInstancesClient( + TargetInstancesSettings targetInstancesSettings) throws IOException { + return TargetInstancesClient.create(targetInstancesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-target-instances"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetInstancesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetInstancesSpringProperties.java new file mode 100644 index 0000000000..017c60a5a5 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetInstancesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for TargetInstances client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.target-instances") +public class TargetInstancesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetPoolsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetPoolsSpringAutoConfiguration.java new file mode 100644 index 0000000000..c798dce025 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetPoolsSpringAutoConfiguration.java @@ -0,0 +1,236 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.TargetPoolsClient; +import com.google.cloud.compute.v1.TargetPoolsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link TargetPoolsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(TargetPoolsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.target-pools.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(TargetPoolsSpringProperties.class) +public class TargetPoolsSpringAutoConfiguration { + private final TargetPoolsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(TargetPoolsSpringAutoConfiguration.class); + + protected TargetPoolsSpringAutoConfiguration( + TargetPoolsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from TargetPools-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultTargetPoolsTransportChannelProvider") + public TransportChannelProvider defaultTargetPoolsTransportChannelProvider() { + return TargetPoolsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a TargetPoolsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultTargetPoolsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in TargetPoolsSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link TargetPoolsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public TargetPoolsSettings targetPoolsSettings( + @Qualifier("defaultTargetPoolsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + TargetPoolsSettings.Builder clientSettingsBuilder = TargetPoolsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + TargetPoolsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getHealthRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getHealthSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getHealthSettings().setRetrySettings(getHealthRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getHealthRetry = clientProperties.getGetHealthRetry(); + if (getHealthRetry != null) { + RetrySettings getHealthRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getHealthSettings().getRetrySettings(), getHealthRetry); + clientSettingsBuilder.getHealthSettings().setRetrySettings(getHealthRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getHealth from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a TargetPoolsClient bean configured with TargetPoolsSettings. + * + * @param targetPoolsSettings settings to configure an instance of client bean. + * @return a {@link TargetPoolsClient} bean configured with {@link TargetPoolsSettings} + */ + @Bean + @ConditionalOnMissingBean + public TargetPoolsClient targetPoolsClient(TargetPoolsSettings targetPoolsSettings) + throws IOException { + return TargetPoolsClient.create(targetPoolsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-target-pools"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetPoolsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetPoolsSpringProperties.java new file mode 100644 index 0000000000..db7422f96d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetPoolsSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for TargetPools client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.target-pools") +public class TargetPoolsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getHealth. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getHealthRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetHealthRetry() { + return this.getHealthRetry; + } + + public void setGetHealthRetry(Retry getHealthRetry) { + this.getHealthRetry = getHealthRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetSslProxiesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetSslProxiesSpringAutoConfiguration.java new file mode 100644 index 0000000000..0874b1f572 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetSslProxiesSpringAutoConfiguration.java @@ -0,0 +1,207 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.TargetSslProxiesClient; +import com.google.cloud.compute.v1.TargetSslProxiesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link TargetSslProxiesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(TargetSslProxiesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.target-ssl-proxies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(TargetSslProxiesSpringProperties.class) +public class TargetSslProxiesSpringAutoConfiguration { + private final TargetSslProxiesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(TargetSslProxiesSpringAutoConfiguration.class); + + protected TargetSslProxiesSpringAutoConfiguration( + TargetSslProxiesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from TargetSslProxies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultTargetSslProxiesTransportChannelProvider") + public TransportChannelProvider defaultTargetSslProxiesTransportChannelProvider() { + return TargetSslProxiesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a TargetSslProxiesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultTargetSslProxiesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in TargetSslProxiesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link TargetSslProxiesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public TargetSslProxiesSettings targetSslProxiesSettings( + @Qualifier("defaultTargetSslProxiesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + TargetSslProxiesSettings.Builder clientSettingsBuilder = TargetSslProxiesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + TargetSslProxiesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a TargetSslProxiesClient bean configured with TargetSslProxiesSettings. + * + * @param targetSslProxiesSettings settings to configure an instance of client bean. + * @return a {@link TargetSslProxiesClient} bean configured with {@link TargetSslProxiesSettings} + */ + @Bean + @ConditionalOnMissingBean + public TargetSslProxiesClient targetSslProxiesClient( + TargetSslProxiesSettings targetSslProxiesSettings) throws IOException { + return TargetSslProxiesClient.create(targetSslProxiesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-target-ssl-proxies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetSslProxiesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetSslProxiesSpringProperties.java new file mode 100644 index 0000000000..de58f34d4d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetSslProxiesSpringProperties.java @@ -0,0 +1,100 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for TargetSslProxies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.target-ssl-proxies") +public class TargetSslProxiesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetTcpProxiesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetTcpProxiesSpringAutoConfiguration.java new file mode 100644 index 0000000000..897d319dab --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetTcpProxiesSpringAutoConfiguration.java @@ -0,0 +1,223 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.TargetTcpProxiesClient; +import com.google.cloud.compute.v1.TargetTcpProxiesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link TargetTcpProxiesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(TargetTcpProxiesClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.target-tcp-proxies.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(TargetTcpProxiesSpringProperties.class) +public class TargetTcpProxiesSpringAutoConfiguration { + private final TargetTcpProxiesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(TargetTcpProxiesSpringAutoConfiguration.class); + + protected TargetTcpProxiesSpringAutoConfiguration( + TargetTcpProxiesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from TargetTcpProxies-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultTargetTcpProxiesTransportChannelProvider") + public TransportChannelProvider defaultTargetTcpProxiesTransportChannelProvider() { + return TargetTcpProxiesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a TargetTcpProxiesSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultTargetTcpProxiesTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in TargetTcpProxiesSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link TargetTcpProxiesSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public TargetTcpProxiesSettings targetTcpProxiesSettings( + @Qualifier("defaultTargetTcpProxiesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + TargetTcpProxiesSettings.Builder clientSettingsBuilder = TargetTcpProxiesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + TargetTcpProxiesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a TargetTcpProxiesClient bean configured with TargetTcpProxiesSettings. + * + * @param targetTcpProxiesSettings settings to configure an instance of client bean. + * @return a {@link TargetTcpProxiesClient} bean configured with {@link TargetTcpProxiesSettings} + */ + @Bean + @ConditionalOnMissingBean + public TargetTcpProxiesClient targetTcpProxiesClient( + TargetTcpProxiesSettings targetTcpProxiesSettings) throws IOException { + return TargetTcpProxiesClient.create(targetTcpProxiesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-target-tcp-proxies"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetTcpProxiesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetTcpProxiesSpringProperties.java new file mode 100644 index 0000000000..9a2bfc8670 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetTcpProxiesSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for TargetTcpProxies client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.target-tcp-proxies") +public class TargetTcpProxiesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetVpnGatewaysSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetVpnGatewaysSpringAutoConfiguration.java new file mode 100644 index 0000000000..ddaaeee8ee --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetVpnGatewaysSpringAutoConfiguration.java @@ -0,0 +1,225 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.TargetVpnGatewaysClient; +import com.google.cloud.compute.v1.TargetVpnGatewaysSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link TargetVpnGatewaysClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(TargetVpnGatewaysClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.target-vpn-gateways.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(TargetVpnGatewaysSpringProperties.class) +public class TargetVpnGatewaysSpringAutoConfiguration { + private final TargetVpnGatewaysSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = + LogFactory.getLog(TargetVpnGatewaysSpringAutoConfiguration.class); + + protected TargetVpnGatewaysSpringAutoConfiguration( + TargetVpnGatewaysSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from TargetVpnGateways-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultTargetVpnGatewaysTransportChannelProvider") + public TransportChannelProvider defaultTargetVpnGatewaysTransportChannelProvider() { + return TargetVpnGatewaysSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a TargetVpnGatewaysSettings bean configured to use a DefaultCredentialsProvider and + * the client library's default transport channel provider + * (defaultTargetVpnGatewaysTransportChannelProvider()). It also configures the quota project ID + * and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in TargetVpnGatewaysSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link TargetVpnGatewaysSettings} bean configured with {@link + * TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public TargetVpnGatewaysSettings targetVpnGatewaysSettings( + @Qualifier("defaultTargetVpnGatewaysTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + TargetVpnGatewaysSettings.Builder clientSettingsBuilder = + TargetVpnGatewaysSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + TargetVpnGatewaysSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a TargetVpnGatewaysClient bean configured with TargetVpnGatewaysSettings. + * + * @param targetVpnGatewaysSettings settings to configure an instance of client bean. + * @return a {@link TargetVpnGatewaysClient} bean configured with {@link + * TargetVpnGatewaysSettings} + */ + @Bean + @ConditionalOnMissingBean + public TargetVpnGatewaysClient targetVpnGatewaysClient( + TargetVpnGatewaysSettings targetVpnGatewaysSettings) throws IOException { + return TargetVpnGatewaysClient.create(targetVpnGatewaysSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-target-vpn-gateways"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetVpnGatewaysSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetVpnGatewaysSpringProperties.java new file mode 100644 index 0000000000..56b3a26f7e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/TargetVpnGatewaysSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for TargetVpnGateways client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.target-vpn-gateways") +public class TargetVpnGatewaysSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/UrlMapsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/UrlMapsSpringAutoConfiguration.java new file mode 100644 index 0000000000..f19a21a2ae --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/UrlMapsSpringAutoConfiguration.java @@ -0,0 +1,233 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.UrlMapsClient; +import com.google.cloud.compute.v1.UrlMapsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link UrlMapsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(UrlMapsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.url-maps.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(UrlMapsSpringProperties.class) +public class UrlMapsSpringAutoConfiguration { + private final UrlMapsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(UrlMapsSpringAutoConfiguration.class); + + protected UrlMapsSpringAutoConfiguration( + UrlMapsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from UrlMaps-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultUrlMapsTransportChannelProvider") + public TransportChannelProvider defaultUrlMapsTransportChannelProvider() { + return UrlMapsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a UrlMapsSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultUrlMapsTransportChannelProvider()). It + * also configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in UrlMapsSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link UrlMapsSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public UrlMapsSettings urlMapsSettings( + @Qualifier("defaultUrlMapsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + UrlMapsSettings.Builder clientSettingsBuilder = UrlMapsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + UrlMapsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings validateRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.validateSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.validateSettings().setRetrySettings(validateRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry validateRetry = clientProperties.getValidateRetry(); + if (validateRetry != null) { + RetrySettings validateRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.validateSettings().getRetrySettings(), validateRetry); + clientSettingsBuilder.validateSettings().setRetrySettings(validateRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for validate from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a UrlMapsClient bean configured with UrlMapsSettings. + * + * @param urlMapsSettings settings to configure an instance of client bean. + * @return a {@link UrlMapsClient} bean configured with {@link UrlMapsSettings} + */ + @Bean + @ConditionalOnMissingBean + public UrlMapsClient urlMapsClient(UrlMapsSettings urlMapsSettings) throws IOException { + return UrlMapsClient.create(urlMapsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-url-maps"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/UrlMapsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/UrlMapsSpringProperties.java new file mode 100644 index 0000000000..82957f589b --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/UrlMapsSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for UrlMaps client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.url-maps") +public class UrlMapsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for validate. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry validateRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getValidateRetry() { + return this.validateRetry; + } + + public void setValidateRetry(Retry validateRetry) { + this.validateRetry = validateRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnGatewaysSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnGatewaysSpringAutoConfiguration.java new file mode 100644 index 0000000000..decca8418d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnGatewaysSpringAutoConfiguration.java @@ -0,0 +1,257 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.VpnGatewaysClient; +import com.google.cloud.compute.v1.VpnGatewaysSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link VpnGatewaysClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(VpnGatewaysClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.vpn-gateways.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(VpnGatewaysSpringProperties.class) +public class VpnGatewaysSpringAutoConfiguration { + private final VpnGatewaysSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(VpnGatewaysSpringAutoConfiguration.class); + + protected VpnGatewaysSpringAutoConfiguration( + VpnGatewaysSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from VpnGateways-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultVpnGatewaysTransportChannelProvider") + public TransportChannelProvider defaultVpnGatewaysTransportChannelProvider() { + return VpnGatewaysSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a VpnGatewaysSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultVpnGatewaysTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in VpnGatewaysSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link VpnGatewaysSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public VpnGatewaysSettings vpnGatewaysSettings( + @Qualifier("defaultVpnGatewaysTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + VpnGatewaysSettings.Builder clientSettingsBuilder = VpnGatewaysSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + VpnGatewaysSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings getStatusRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getStatusSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getStatusSettings().setRetrySettings(getStatusRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry getStatusRetry = clientProperties.getGetStatusRetry(); + if (getStatusRetry != null) { + RetrySettings getStatusRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getStatusSettings().getRetrySettings(), getStatusRetry); + clientSettingsBuilder.getStatusSettings().setRetrySettings(getStatusRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for getStatus from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry testIamPermissionsRetry = clientProperties.getTestIamPermissionsRetry(); + if (testIamPermissionsRetry != null) { + RetrySettings testIamPermissionsRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.testIamPermissionsSettings().getRetrySettings(), + testIamPermissionsRetry); + clientSettingsBuilder + .testIamPermissionsSettings() + .setRetrySettings(testIamPermissionsRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Configured method-level retry settings for testIamPermissions from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a VpnGatewaysClient bean configured with VpnGatewaysSettings. + * + * @param vpnGatewaysSettings settings to configure an instance of client bean. + * @return a {@link VpnGatewaysClient} bean configured with {@link VpnGatewaysSettings} + */ + @Bean + @ConditionalOnMissingBean + public VpnGatewaysClient vpnGatewaysClient(VpnGatewaysSettings vpnGatewaysSettings) + throws IOException { + return VpnGatewaysClient.create(vpnGatewaysSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-vpn-gateways"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnGatewaysSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnGatewaysSpringProperties.java new file mode 100644 index 0000000000..00ec3e3155 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnGatewaysSpringProperties.java @@ -0,0 +1,139 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for VpnGateways client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.vpn-gateways") +public class VpnGatewaysSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for getStatus. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getStatusRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for testIamPermissions. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry testIamPermissionsRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getGetStatusRetry() { + return this.getStatusRetry; + } + + public void setGetStatusRetry(Retry getStatusRetry) { + this.getStatusRetry = getStatusRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getTestIamPermissionsRetry() { + return this.testIamPermissionsRetry; + } + + public void setTestIamPermissionsRetry(Retry testIamPermissionsRetry) { + this.testIamPermissionsRetry = testIamPermissionsRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnTunnelsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnTunnelsSpringAutoConfiguration.java new file mode 100644 index 0000000000..9868bab7f6 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnTunnelsSpringAutoConfiguration.java @@ -0,0 +1,221 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.VpnTunnelsClient; +import com.google.cloud.compute.v1.VpnTunnelsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link VpnTunnelsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(VpnTunnelsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.vpn-tunnels.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(VpnTunnelsSpringProperties.class) +public class VpnTunnelsSpringAutoConfiguration { + private final VpnTunnelsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(VpnTunnelsSpringAutoConfiguration.class); + + protected VpnTunnelsSpringAutoConfiguration( + VpnTunnelsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from VpnTunnels-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultVpnTunnelsTransportChannelProvider") + public TransportChannelProvider defaultVpnTunnelsTransportChannelProvider() { + return VpnTunnelsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a VpnTunnelsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultVpnTunnelsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in VpnTunnelsSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link VpnTunnelsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public VpnTunnelsSettings vpnTunnelsSettings( + @Qualifier("defaultVpnTunnelsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + VpnTunnelsSettings.Builder clientSettingsBuilder = VpnTunnelsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + VpnTunnelsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry aggregatedListRetry = clientProperties.getAggregatedListRetry(); + if (aggregatedListRetry != null) { + RetrySettings aggregatedListRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.aggregatedListSettings().getRetrySettings(), + aggregatedListRetry); + clientSettingsBuilder.aggregatedListSettings().setRetrySettings(aggregatedListRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for aggregatedList from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a VpnTunnelsClient bean configured with VpnTunnelsSettings. + * + * @param vpnTunnelsSettings settings to configure an instance of client bean. + * @return a {@link VpnTunnelsClient} bean configured with {@link VpnTunnelsSettings} + */ + @Bean + @ConditionalOnMissingBean + public VpnTunnelsClient vpnTunnelsClient(VpnTunnelsSettings vpnTunnelsSettings) + throws IOException { + return VpnTunnelsClient.create(vpnTunnelsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-vpn-tunnels"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnTunnelsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnTunnelsSpringProperties.java new file mode 100644 index 0000000000..3a68b1283e --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/VpnTunnelsSpringProperties.java @@ -0,0 +1,113 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for VpnTunnels client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.vpn-tunnels") +public class VpnTunnelsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for aggregatedList. If defined, this takes + * precedence over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry aggregatedListRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getAggregatedListRetry() { + return this.aggregatedListRetry; + } + + public void setAggregatedListRetry(Retry aggregatedListRetry) { + this.aggregatedListRetry = aggregatedListRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZoneOperationsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZoneOperationsSpringAutoConfiguration.java new file mode 100644 index 0000000000..391398187d --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZoneOperationsSpringAutoConfiguration.java @@ -0,0 +1,236 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ZoneOperationsClient; +import com.google.cloud.compute.v1.ZoneOperationsSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ZoneOperationsClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ZoneOperationsClient.class) +@ConditionalOnProperty( + value = "com.google.cloud.compute.v1.zone-operations.enabled", + matchIfMissing = true) +@EnableConfigurationProperties(ZoneOperationsSpringProperties.class) +public class ZoneOperationsSpringAutoConfiguration { + private final ZoneOperationsSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(ZoneOperationsSpringAutoConfiguration.class); + + protected ZoneOperationsSpringAutoConfiguration( + ZoneOperationsSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from ZoneOperations-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultZoneOperationsTransportChannelProvider") + public TransportChannelProvider defaultZoneOperationsTransportChannelProvider() { + return ZoneOperationsSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ZoneOperationsSettings bean configured to use a DefaultCredentialsProvider and the + * client library's default transport channel provider + * (defaultZoneOperationsTransportChannelProvider()). It also configures the quota project ID and + * executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ZoneOperationsSpringProperties. Method-level properties will take precedence over + * service-level properties if available, and client library defaults will be used if neither are + * specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ZoneOperationsSettings} bean configured with {@link TransportChannelProvider} + * bean. + */ + @Bean + @ConditionalOnMissingBean + public ZoneOperationsSettings zoneOperationsSettings( + @Qualifier("defaultZoneOperationsTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ZoneOperationsSettings.Builder clientSettingsBuilder = ZoneOperationsSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ZoneOperationsSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings deleteRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.deleteSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.deleteSettings().setRetrySettings(deleteRetrySettings); + + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + RetrySettings waitRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.waitSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.waitSettings().setRetrySettings(waitRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry deleteRetry = clientProperties.getDeleteRetry(); + if (deleteRetry != null) { + RetrySettings deleteRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.deleteSettings().getRetrySettings(), deleteRetry); + clientSettingsBuilder.deleteSettings().setRetrySettings(deleteRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for delete from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + Retry waitRetry = clientProperties.getWaitRetry(); + if (waitRetry != null) { + RetrySettings waitRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.waitSettings().getRetrySettings(), waitRetry); + clientSettingsBuilder.waitSettings().setRetrySettings(waitRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for wait from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ZoneOperationsClient bean configured with ZoneOperationsSettings. + * + * @param zoneOperationsSettings settings to configure an instance of client bean. + * @return a {@link ZoneOperationsClient} bean configured with {@link ZoneOperationsSettings} + */ + @Bean + @ConditionalOnMissingBean + public ZoneOperationsClient zoneOperationsClient(ZoneOperationsSettings zoneOperationsSettings) + throws IOException { + return ZoneOperationsClient.create(zoneOperationsSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-zone-operations"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZoneOperationsSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZoneOperationsSpringProperties.java new file mode 100644 index 0000000000..e85b44cfa6 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZoneOperationsSpringProperties.java @@ -0,0 +1,126 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for ZoneOperations client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.zone-operations") +public class ZoneOperationsSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for delete. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry deleteRetry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + /** + * Allow override of retry settings at method-level for wait. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry waitRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getDeleteRetry() { + return this.deleteRetry; + } + + public void setDeleteRetry(Retry deleteRetry) { + this.deleteRetry = deleteRetry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } + + public Retry getWaitRetry() { + return this.waitRetry; + } + + public void setWaitRetry(Retry waitRetry) { + this.waitRetry = waitRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZonesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZonesSpringAutoConfiguration.java new file mode 100644 index 0000000000..e875854b13 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZonesSpringAutoConfiguration.java @@ -0,0 +1,200 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.ExecutorProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.compute.v1.ZonesClient; +import com.google.cloud.compute.v1.ZonesSettings; +import com.google.cloud.spring.autoconfigure.core.GcpContextAutoConfiguration; +import com.google.cloud.spring.core.DefaultCredentialsProvider; +import com.google.cloud.spring.core.Retry; +import com.google.cloud.spring.core.util.RetryUtil; +import java.io.IOException; +import java.util.Collections; +import javax.annotation.Generated; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Auto-configuration for {@link ZonesClient}. + * + *

Provides auto-configuration for Spring Boot + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default transport provider is used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@AutoConfiguration +@AutoConfigureAfter(GcpContextAutoConfiguration.class) +@ConditionalOnClass(ZonesClient.class) +@ConditionalOnProperty(value = "com.google.cloud.compute.v1.zones.enabled", matchIfMissing = true) +@EnableConfigurationProperties(ZonesSpringProperties.class) +public class ZonesSpringAutoConfiguration { + private final ZonesSpringProperties clientProperties; + private final CredentialsProvider credentialsProvider; + private static final Log LOGGER = LogFactory.getLog(ZonesSpringAutoConfiguration.class); + + protected ZonesSpringAutoConfiguration( + ZonesSpringProperties clientProperties, CredentialsProvider credentialsProvider) + throws IOException { + this.clientProperties = clientProperties; + if (this.clientProperties.getCredentials().hasKey()) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Using credentials from Zones-specific configuration"); + } + this.credentialsProvider = + ((CredentialsProvider) new DefaultCredentialsProvider(this.clientProperties)); + } else { + this.credentialsProvider = credentialsProvider; + } + } + + /** + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. + * + * @return a default transport channel provider. + */ + @Bean + @ConditionalOnMissingBean(name = "defaultZonesTransportChannelProvider") + public TransportChannelProvider defaultZonesTransportChannelProvider() { + return ZonesSettings.defaultTransportChannelProvider(); + } + + /** + * Provides a ZonesSettings bean configured to use a DefaultCredentialsProvider and the client + * library's default transport channel provider (defaultZonesTransportChannelProvider()). It also + * configures the quota project ID and executor thread count, if provided through properties. + * + *

Retry settings are also configured from service-level and method-level properties specified + * in ZonesSpringProperties. Method-level properties will take precedence over service-level + * properties if available, and client library defaults will be used if neither are specified. + * + * @param defaultTransportChannelProvider TransportChannelProvider to use in the settings. + * @return a {@link ZonesSettings} bean configured with {@link TransportChannelProvider} bean. + */ + @Bean + @ConditionalOnMissingBean + public ZonesSettings zonesSettings( + @Qualifier("defaultZonesTransportChannelProvider") + TransportChannelProvider defaultTransportChannelProvider) + throws IOException { + ZonesSettings.Builder clientSettingsBuilder = ZonesSettings.newBuilder(); + clientSettingsBuilder + .setCredentialsProvider(this.credentialsProvider) + .setTransportChannelProvider(defaultTransportChannelProvider) + .setHeaderProvider(this.userAgentHeaderProvider()); + if (this.clientProperties.getQuotaProjectId() != null) { + clientSettingsBuilder.setQuotaProjectId(this.clientProperties.getQuotaProjectId()); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Quota project id set to " + + this.clientProperties.getQuotaProjectId() + + ", this overrides project id from credentials."); + } + } + if (this.clientProperties.getExecutorThreadCount() != null) { + ExecutorProvider executorProvider = + ZonesSettings.defaultExecutorProviderBuilder() + .setExecutorThreadCount(this.clientProperties.getExecutorThreadCount()) + .build(); + clientSettingsBuilder.setBackgroundExecutorProvider(executorProvider); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace( + "Background executor thread count is " + + this.clientProperties.getExecutorThreadCount()); + } + } + Retry serviceRetry = clientProperties.getRetry(); + if (serviceRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), serviceRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured service-level retry settings from properties."); + } + } + Retry getRetry = clientProperties.getGetRetry(); + if (getRetry != null) { + RetrySettings getRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.getSettings().getRetrySettings(), getRetry); + clientSettingsBuilder.getSettings().setRetrySettings(getRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for get from properties."); + } + } + Retry listRetry = clientProperties.getListRetry(); + if (listRetry != null) { + RetrySettings listRetrySettings = + RetryUtil.updateRetrySettings( + clientSettingsBuilder.listSettings().getRetrySettings(), listRetry); + clientSettingsBuilder.listSettings().setRetrySettings(listRetrySettings); + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("Configured method-level retry settings for list from properties."); + } + } + return clientSettingsBuilder.build(); + } + + /** + * Provides a ZonesClient bean configured with ZonesSettings. + * + * @param zonesSettings settings to configure an instance of client bean. + * @return a {@link ZonesClient} bean configured with {@link ZonesSettings} + */ + @Bean + @ConditionalOnMissingBean + public ZonesClient zonesClient(ZonesSettings zonesSettings) throws IOException { + return ZonesClient.create(zonesSettings); + } + + private HeaderProvider userAgentHeaderProvider() { + String springLibrary = "spring-autogen-zones"; + String version = this.getClass().getPackage().getImplementationVersion(); + return () -> Collections.singletonMap("user-agent", springLibrary + "/" + version); + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZonesSpringProperties.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZonesSpringProperties.java new file mode 100644 index 0000000000..4c3aeffdba --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/ZonesSpringProperties.java @@ -0,0 +1,101 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import com.google.cloud.spring.core.Credentials; +import com.google.cloud.spring.core.CredentialsSupplier; +import com.google.cloud.spring.core.Retry; +import javax.annotation.Generated; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** Provides default property values for Zones client bean */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +@ConfigurationProperties("com.google.cloud.compute.v1.zones") +public class ZonesSpringProperties implements CredentialsSupplier { + /** OAuth2 credentials to authenticate and authorize calls to Google Cloud Client Libraries. */ + @NestedConfigurationProperty + private final Credentials credentials = + new Credentials( + "https://www.googleapis.com/auth/compute.readonly", + "https://www.googleapis.com/auth/compute", + "https://www.googleapis.com/auth/cloud-platform"); + /** Quota project to use for billing. */ + private String quotaProjectId; + /** Number of threads used for executors. */ + private Integer executorThreadCount; + /** Allow override of retry settings at service level, applying to all of its RPC methods. */ + @NestedConfigurationProperty private Retry retry; + /** + * Allow override of retry settings at method-level for get. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry getRetry; + /** + * Allow override of retry settings at method-level for list. If defined, this takes precedence + * over service-level retry configurations for that RPC method. + */ + @NestedConfigurationProperty private Retry listRetry; + + @Override + public Credentials getCredentials() { + return this.credentials; + } + + public String getQuotaProjectId() { + return this.quotaProjectId; + } + + public void setQuotaProjectId(String quotaProjectId) { + this.quotaProjectId = quotaProjectId; + } + + public Integer getExecutorThreadCount() { + return this.executorThreadCount; + } + + public void setExecutorThreadCount(Integer executorThreadCount) { + this.executorThreadCount = executorThreadCount; + } + + public Retry getRetry() { + return this.retry; + } + + public void setRetry(Retry retry) { + this.retry = retry; + } + + public Retry getGetRetry() { + return this.getRetry; + } + + public void setGetRetry(Retry getRetry) { + this.getRetry = getRetry; + } + + public Retry getListRetry() { + return this.listRetry; + } + + public void setListRetry(Retry listRetry) { + this.listRetry = listRetry; + } +} diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/package-info.java new file mode 100644 index 0000000000..e058ce1549 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/java/com/google/cloud/compute/v1/spring/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2023 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** Spring Boot auto-configurations for compute. */ +@Generated("by google-cloud-spring-generator") +@BetaApi("Autogenerated Spring autoconfiguration is not yet stable") +package com.google.cloud.compute.v1.spring; + +import com.google.api.core.BetaApi; +import javax.annotation.Generated; diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json new file mode 100644 index 0000000000..39a30828b7 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -0,0 +1,538 @@ +{ + "properties": [ + { + "name": "com.google.cloud.compute.v1.accelerator-types.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/AcceleratorTypes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.addresses.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Addresses components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.autoscalers.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Autoscalers components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.backend-buckets.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/BackendBuckets components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.backend-services.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/BackendServices components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.disk-types.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/DiskTypes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.disks.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Disks components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.external-vpn-gateways.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/ExternalVpnGateways components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.firewall-policies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/FirewallPolicies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.firewalls.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Firewalls components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.forwarding-rules.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/ForwardingRules components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.global-addresses.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/GlobalAddresses components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.global-forwarding-rules.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/GlobalForwardingRules components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.global-network-endpoint-groups.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/GlobalNetworkEndpointGroups components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.global-operations.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/GlobalOperations components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.global-organization-operations.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/GlobalOrganizationOperations components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.global-public-delegated-prefixes.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/GlobalPublicDelegatedPrefixes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.health-checks.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/HealthChecks components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.image-family-views.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/ImageFamilyViews components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.images.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Images components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.instance-group-managers.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/InstanceGroupManagers components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.instance-groups.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/InstanceGroups components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.instance-templates.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/InstanceTemplates components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.instances.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Instances components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.interconnect-attachments.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/InterconnectAttachments components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.interconnect-locations.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/InterconnectLocations components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.interconnects.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Interconnects components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.license-codes.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/LicenseCodes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.licenses.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Licenses components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.machine-images.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/MachineImages components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.machine-types.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/MachineTypes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.network-attachments.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/NetworkAttachments components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.network-edge-security-services.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/NetworkEdgeSecurityServices components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.network-endpoint-groups.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/NetworkEndpointGroups components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.network-firewall-policies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/NetworkFirewallPolicies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.networks.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Networks components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.node-groups.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/NodeGroups components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.node-templates.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/NodeTemplates components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.node-types.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/NodeTypes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.packet-mirrorings.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/PacketMirrorings components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.projects.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Projects components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.public-advertised-prefixes.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/PublicAdvertisedPrefixes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.public-delegated-prefixes.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/PublicDelegatedPrefixes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-autoscalers.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionAutoscalers components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-backend-services.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionBackendServices components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-commitments.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionCommitments components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-disk-types.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionDiskTypes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-disks.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionDisks components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-health-check-services.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionHealthCheckServices components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-health-checks.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionHealthChecks components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-instance-group-managers.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionInstanceGroupManagers components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-instance-groups.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionInstanceGroups components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-instance-templates.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionInstanceTemplates components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-instances.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionInstances components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-network-endpoint-groups.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionNetworkEndpointGroups components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-network-firewall-policies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionNetworkFirewallPolicies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-notification-endpoints.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionNotificationEndpoints components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-operations.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionOperations components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-security-policies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionSecurityPolicies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-ssl-certificates.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionSslCertificates components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-ssl-policies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionSslPolicies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-target-http-proxies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionTargetHttpProxies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-target-https-proxies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionTargetHttpsProxies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-target-tcp-proxies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionTargetTcpProxies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.region-url-maps.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/RegionUrlMaps components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.regions.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Regions components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.reservations.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Reservations components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.resource-policies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/ResourcePolicies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.routers.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Routers components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.routes.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Routes components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.security-policies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/SecurityPolicies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.service-attachments.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/ServiceAttachments components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.snapshots.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Snapshots components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.ssl-certificates.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/SslCertificates components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.ssl-policies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/SslPolicies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.subnetworks.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Subnetworks components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.target-grpc-proxies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/TargetGrpcProxies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.target-http-proxies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/TargetHttpProxies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.target-https-proxies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/TargetHttpsProxies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.target-instances.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/TargetInstances components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.target-pools.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/TargetPools components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.target-ssl-proxies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/TargetSslProxies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.target-tcp-proxies.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/TargetTcpProxies components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.target-vpn-gateways.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/TargetVpnGateways components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.url-maps.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/UrlMaps components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.vpn-gateways.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/VpnGateways components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.vpn-tunnels.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/VpnTunnels components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.zone-operations.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/ZoneOperations components.", + "defaultValue": true + }, + { + "name": "com.google.cloud.compute.v1.zones.enabled", + "type": "java.lang.Boolean", + "description": "Auto-configure Google Cloud compute/Zones components.", + "defaultValue": true + } + ] +} \ No newline at end of file diff --git a/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..e8e86cfbb3 --- /dev/null +++ b/spring-cloud-previews/google-cloud-compute-spring-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1,89 @@ +com.google.cloud.compute.v1.spring.AcceleratorTypesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.AddressesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.AutoscalersSpringAutoConfiguration +com.google.cloud.compute.v1.spring.BackendBucketsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.BackendServicesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.DiskTypesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.DisksSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ExternalVpnGatewaysSpringAutoConfiguration +com.google.cloud.compute.v1.spring.FirewallPoliciesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.FirewallsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ForwardingRulesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.GlobalAddressesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.GlobalForwardingRulesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.GlobalNetworkEndpointGroupsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.GlobalOperationsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.GlobalOrganizationOperationsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.GlobalPublicDelegatedPrefixesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.HealthChecksSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ImageFamilyViewsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ImagesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.InstanceGroupManagersSpringAutoConfiguration +com.google.cloud.compute.v1.spring.InstanceGroupsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.InstanceTemplatesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.InstancesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.InterconnectAttachmentsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.InterconnectLocationsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.InterconnectsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.LicenseCodesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.LicensesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.MachineImagesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.MachineTypesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.NetworkAttachmentsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.NetworkEdgeSecurityServicesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.NetworkEndpointGroupsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.NetworkFirewallPoliciesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.NetworksSpringAutoConfiguration +com.google.cloud.compute.v1.spring.NodeGroupsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.NodeTemplatesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.NodeTypesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.PacketMirroringsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ProjectsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.PublicAdvertisedPrefixesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.PublicDelegatedPrefixesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionAutoscalersSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionBackendServicesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionCommitmentsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionDiskTypesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionDisksSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionHealthCheckServicesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionHealthChecksSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionInstanceGroupManagersSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionInstanceGroupsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionInstanceTemplatesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionInstancesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionNetworkEndpointGroupsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionNetworkFirewallPoliciesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionNotificationEndpointsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionOperationsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionSecurityPoliciesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionSslCertificatesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionSslPoliciesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionTargetHttpProxiesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionTargetHttpsProxiesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionTargetTcpProxiesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionUrlMapsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RegionsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ReservationsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ResourcePoliciesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RoutersSpringAutoConfiguration +com.google.cloud.compute.v1.spring.RoutesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.SecurityPoliciesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ServiceAttachmentsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.SnapshotsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.SslCertificatesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.SslPoliciesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.SubnetworksSpringAutoConfiguration +com.google.cloud.compute.v1.spring.TargetGrpcProxiesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.TargetHttpProxiesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.TargetHttpsProxiesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.TargetInstancesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.TargetPoolsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.TargetSslProxiesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.TargetTcpProxiesSpringAutoConfiguration +com.google.cloud.compute.v1.spring.TargetVpnGatewaysSpringAutoConfiguration +com.google.cloud.compute.v1.spring.UrlMapsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.VpnGatewaysSpringAutoConfiguration +com.google.cloud.compute.v1.spring.VpnTunnelsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ZoneOperationsSpringAutoConfiguration +com.google.cloud.compute.v1.spring.ZonesSpringAutoConfiguration \ No newline at end of file diff --git a/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/ContactCenterInsightsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/ContactCenterInsightsSpringAutoConfiguration.java index d805cc9e45..68508f7bdf 100644 --- a/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/ContactCenterInsightsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/ContactCenterInsightsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected ContactCenterInsightsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/ContactCenterInsightsSpringProperties.java b/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/ContactCenterInsightsSpringProperties.java index ec92f68f97..a9144b038b 100644 --- a/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/ContactCenterInsightsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/ContactCenterInsightsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/package-info.java index f1f52b83b1..6db47edcdc 100644 --- a/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-contact-center-insights-spring-starter/src/main/java/com/google/cloud/contactcenterinsights/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/ClusterManagerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/ClusterManagerSpringAutoConfiguration.java index fa3e55282e..3fb655e073 100644 --- a/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/ClusterManagerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/ClusterManagerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ClusterManagerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/ClusterManagerSpringProperties.java b/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/ClusterManagerSpringProperties.java index aa3d23bcf1..7a18c895cd 100644 --- a/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/ClusterManagerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/ClusterManagerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/package-info.java index 160038dd20..6c3843c60c 100644 --- a/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-container-spring-starter/src/main/java/com/google/cloud/container/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/ContainerAnalysisSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/ContainerAnalysisSpringAutoConfiguration.java index 6c9b4a099f..9f5fd7a38d 100644 --- a/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/ContainerAnalysisSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/ContainerAnalysisSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ContainerAnalysisSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/ContainerAnalysisSpringProperties.java b/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/ContainerAnalysisSpringProperties.java index 716608052a..c90064c556 100644 --- a/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/ContainerAnalysisSpringProperties.java +++ b/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/ContainerAnalysisSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/package-info.java index 28b49d7845..024e421ee7 100644 --- a/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-containeranalysis-spring-starter/src/main/java/com/google/cloud/devtools/containeranalysis/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/DataFusionSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/DataFusionSpringAutoConfiguration.java index f447a1aa88..670c9a7b69 100644 --- a/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/DataFusionSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/DataFusionSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DataFusionSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/DataFusionSpringProperties.java b/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/DataFusionSpringProperties.java index 49018fc49a..db06ddaa5f 100644 --- a/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/DataFusionSpringProperties.java +++ b/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/DataFusionSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/package-info.java index 44074c0ef6..7603980770 100644 --- a/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-data-fusion-spring-starter/src/main/java/com/google/cloud/datafusion/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/DataCatalogSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/DataCatalogSpringAutoConfiguration.java index d229ecb8a3..88c0f12c18 100644 --- a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/DataCatalogSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/DataCatalogSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DataCatalogSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/DataCatalogSpringProperties.java b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/DataCatalogSpringProperties.java index 94f4fad6d0..147521add8 100644 --- a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/DataCatalogSpringProperties.java +++ b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/DataCatalogSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSerializationSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSerializationSpringAutoConfiguration.java index 61649cb9b8..48b6ad59ac 100644 --- a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSerializationSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSerializationSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected PolicyTagManagerSerializationSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSerializationSpringProperties.java b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSerializationSpringProperties.java index 1f82bcbc11..4f3c1aae76 100644 --- a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSerializationSpringProperties.java +++ b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSerializationSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSpringAutoConfiguration.java index 9693776575..98e5649e91 100644 --- a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected PolicyTagManagerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSpringProperties.java b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSpringProperties.java index 937f5f25fa..cdf2017f7d 100644 --- a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/PolicyTagManagerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/package-info.java index 9a48b7a1d2..d18d33d6d6 100644 --- a/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-datacatalog-spring-starter/src/main/java/com/google/cloud/datacatalog/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/ContentServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/ContentServiceSpringAutoConfiguration.java index 9a58611e5d..974d6f3692 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/ContentServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/ContentServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ContentServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/ContentServiceSpringProperties.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/ContentServiceSpringProperties.java index 77cac89797..ad985911ab 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/ContentServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/ContentServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataScanServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataScanServiceSpringAutoConfiguration.java index 08f70c9db7..9d0ba971dd 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataScanServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataScanServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DataScanServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataScanServiceSpringProperties.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataScanServiceSpringProperties.java index a677f0aa53..ad3cb23f38 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataScanServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataScanServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataplexServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataplexServiceSpringAutoConfiguration.java index 1129480a9d..52c4028dd1 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataplexServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataplexServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DataplexServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataplexServiceSpringProperties.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataplexServiceSpringProperties.java index 31620eb248..f5e76b94d9 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataplexServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/DataplexServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/MetadataServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/MetadataServiceSpringAutoConfiguration.java index 9ab4d58d1a..f3be350e87 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/MetadataServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/MetadataServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected MetadataServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/MetadataServiceSpringProperties.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/MetadataServiceSpringProperties.java index 2f239741f4..059393e86b 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/MetadataServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/MetadataServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/package-info.java index 8d86d73948..cfd3436cea 100644 --- a/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-dataplex-spring-starter/src/main/java/com/google/cloud/dataplex/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreFederationSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreFederationSpringAutoConfiguration.java index 3fdb29dab2..f23d009501 100644 --- a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreFederationSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreFederationSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected DataprocMetastoreFederationSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreFederationSpringProperties.java b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreFederationSpringProperties.java index 8ccf23e860..f1b768a416 100644 --- a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreFederationSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreFederationSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreSpringAutoConfiguration.java index 512db7852c..17de83c4e0 100644 --- a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected DataprocMetastoreSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreSpringProperties.java b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreSpringProperties.java index bbcb9d154c..b39bdbb1af 100644 --- a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/DataprocMetastoreSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/package-info.java index bf873848b9..69bb9cb100 100644 --- a/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-dataproc-metastore-spring-starter/src/main/java/com/google/cloud/metastore/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/AutoscalingPolicyServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/AutoscalingPolicyServiceSpringAutoConfiguration.java index ec8548ecfa..85cbab5178 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/AutoscalingPolicyServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/AutoscalingPolicyServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected AutoscalingPolicyServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/AutoscalingPolicyServiceSpringProperties.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/AutoscalingPolicyServiceSpringProperties.java index 0451f4f2a4..5a07014045 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/AutoscalingPolicyServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/AutoscalingPolicyServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/BatchControllerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/BatchControllerSpringAutoConfiguration.java index 4ccf9a7643..0bb353bad2 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/BatchControllerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/BatchControllerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected BatchControllerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/BatchControllerSpringProperties.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/BatchControllerSpringProperties.java index 1b1c13f703..30830d86ce 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/BatchControllerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/BatchControllerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/ClusterControllerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/ClusterControllerSpringAutoConfiguration.java index 19589828bd..b888b0f834 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/ClusterControllerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/ClusterControllerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ClusterControllerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/ClusterControllerSpringProperties.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/ClusterControllerSpringProperties.java index 228def96a0..eb94ea149f 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/ClusterControllerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/ClusterControllerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/JobControllerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/JobControllerSpringAutoConfiguration.java index ef80ac7004..76c509282d 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/JobControllerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/JobControllerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected JobControllerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/JobControllerSpringProperties.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/JobControllerSpringProperties.java index 38650e9cde..d9f02ffb11 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/JobControllerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/JobControllerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/NodeGroupControllerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/NodeGroupControllerSpringAutoConfiguration.java index e2bc0ad27a..ffb68dddc3 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/NodeGroupControllerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/NodeGroupControllerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected NodeGroupControllerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/NodeGroupControllerSpringProperties.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/NodeGroupControllerSpringProperties.java index 671eb9a078..c93175407a 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/NodeGroupControllerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/NodeGroupControllerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/WorkflowTemplateServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/WorkflowTemplateServiceSpringAutoConfiguration.java index 6d8bd89861..301a533a47 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/WorkflowTemplateServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/WorkflowTemplateServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected WorkflowTemplateServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/WorkflowTemplateServiceSpringProperties.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/WorkflowTemplateServiceSpringProperties.java index 680ac507ee..d6302a0035 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/WorkflowTemplateServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/WorkflowTemplateServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/package-info.java index 5a430d89e3..290db1e3f2 100644 --- a/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-dataproc-spring-starter/src/main/java/com/google/cloud/dataproc/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/DatastreamSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/DatastreamSpringAutoConfiguration.java index 47776ea8de..879a194170 100644 --- a/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/DatastreamSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/DatastreamSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DatastreamSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/DatastreamSpringProperties.java b/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/DatastreamSpringProperties.java index f100a683d2..c627d7b3a3 100644 --- a/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/DatastreamSpringProperties.java +++ b/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/DatastreamSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/package-info.java index 545d94e3d9..b6311d7141 100644 --- a/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-datastream-spring-starter/src/main/java/com/google/cloud/datastream/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Controller2SpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Controller2SpringAutoConfiguration.java index ef27b06367..74a16dada3 100644 --- a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Controller2SpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Controller2SpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected Controller2SpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Controller2SpringProperties.java b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Controller2SpringProperties.java index 002522363a..9b4e3943f8 100644 --- a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Controller2SpringProperties.java +++ b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Controller2SpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Debugger2SpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Debugger2SpringAutoConfiguration.java index 8edd8d186c..836fe63610 100644 --- a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Debugger2SpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Debugger2SpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected Debugger2SpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Debugger2SpringProperties.java b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Debugger2SpringProperties.java index 23e9748ad3..cffa82170a 100644 --- a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Debugger2SpringProperties.java +++ b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/Debugger2SpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/package-info.java index a985222a41..161adea6da 100644 --- a/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-debugger-client-spring-starter/src/main/java/com/google/cloud/debugger/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/CloudDeploySpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/CloudDeploySpringAutoConfiguration.java index 8fe03a5463..061f503fa9 100644 --- a/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/CloudDeploySpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/CloudDeploySpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CloudDeploySpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/CloudDeploySpringProperties.java b/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/CloudDeploySpringProperties.java index b4bd09ba84..315c160309 100644 --- a/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/CloudDeploySpringProperties.java +++ b/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/CloudDeploySpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/package-info.java index ada0f7891f..4d923721e3 100644 --- a/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-deploy-spring-starter/src/main/java/com/google/cloud/deploy/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AgentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AgentsSpringAutoConfiguration.java index d60796f9b4..3f3b0d86b4 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AgentsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AgentsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected AgentsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AgentsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AgentsSpringProperties.java index 801c8c48c7..c449a832b9 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AgentsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AgentsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AnswerRecordsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AnswerRecordsSpringAutoConfiguration.java index 0a8085dffe..b44d99ded6 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AnswerRecordsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AnswerRecordsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected AnswerRecordsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AnswerRecordsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AnswerRecordsSpringProperties.java index a188ae6e7f..173b44dab8 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AnswerRecordsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/AnswerRecordsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ContextsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ContextsSpringAutoConfiguration.java index 3902f03d4d..049cec65dc 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ContextsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ContextsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ContextsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ContextsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ContextsSpringProperties.java index 10528bcd23..1902e3f5ae 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ContextsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ContextsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationDatasetsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationDatasetsSpringAutoConfiguration.java index 6f3e744a7b..2fcaa9fef3 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationDatasetsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationDatasetsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected ConversationDatasetsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationDatasetsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationDatasetsSpringProperties.java index 8b7922a480..282bf00ba7 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationDatasetsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationDatasetsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationModelsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationModelsSpringAutoConfiguration.java index 156523eda5..435d4ef4e2 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationModelsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationModelsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ConversationModelsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationModelsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationModelsSpringProperties.java index e5fef002a0..f959827282 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationModelsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationModelsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationProfilesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationProfilesSpringAutoConfiguration.java index 6200b5dbf9..42ac957e43 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationProfilesSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationProfilesSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected ConversationProfilesSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationProfilesSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationProfilesSpringProperties.java index 85549e48e0..83a5271efd 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationProfilesSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationProfilesSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationsSpringAutoConfiguration.java index ac73d7c09f..b38db90b6f 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ConversationsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationsSpringProperties.java index eb90f79777..634dfa1f32 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ConversationsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/DocumentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/DocumentsSpringAutoConfiguration.java index 236fdf00e0..c8b73b0e0b 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/DocumentsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/DocumentsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DocumentsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/DocumentsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/DocumentsSpringProperties.java index 4c6fccab33..50f52b8ae3 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/DocumentsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/DocumentsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EntityTypesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EntityTypesSpringAutoConfiguration.java index 344d73e023..8baef40b04 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EntityTypesSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EntityTypesSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected EntityTypesSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EntityTypesSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EntityTypesSpringProperties.java index 21a5bb01d4..3c9f9f633d 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EntityTypesSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EntityTypesSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EnvironmentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EnvironmentsSpringAutoConfiguration.java index 910567f0c9..e6f6eb5f16 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EnvironmentsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EnvironmentsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected EnvironmentsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EnvironmentsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EnvironmentsSpringProperties.java index bf20fe8289..160b7ac5f1 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EnvironmentsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/EnvironmentsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/FulfillmentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/FulfillmentsSpringAutoConfiguration.java index 7cf68ff07f..7f3635136c 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/FulfillmentsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/FulfillmentsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected FulfillmentsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/FulfillmentsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/FulfillmentsSpringProperties.java index da91ba0428..e0a1cfe485 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/FulfillmentsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/FulfillmentsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/IntentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/IntentsSpringAutoConfiguration.java index f265f0da11..3eed8362ae 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/IntentsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/IntentsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected IntentsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/IntentsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/IntentsSpringProperties.java index 3bb4ec756d..e0d0c2ef96 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/IntentsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/IntentsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/KnowledgeBasesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/KnowledgeBasesSpringAutoConfiguration.java index d1c4c86198..f416c4576f 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/KnowledgeBasesSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/KnowledgeBasesSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected KnowledgeBasesSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/KnowledgeBasesSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/KnowledgeBasesSpringProperties.java index 3a66c150b0..57a0ce2b3c 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/KnowledgeBasesSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/KnowledgeBasesSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ParticipantsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ParticipantsSpringAutoConfiguration.java index 6d6b7ce4a7..7675b0a73f 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ParticipantsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ParticipantsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ParticipantsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ParticipantsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ParticipantsSpringProperties.java index 6dbf3ffc3c..9ce7c735a5 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ParticipantsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/ParticipantsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionEntityTypesSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionEntityTypesSpringAutoConfiguration.java index b9c37865c5..2431edab93 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionEntityTypesSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionEntityTypesSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected SessionEntityTypesSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionEntityTypesSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionEntityTypesSpringProperties.java index 743e29efb6..98a118056e 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionEntityTypesSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionEntityTypesSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionsSpringAutoConfiguration.java index 1b51f04d47..6a2818908c 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected SessionsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionsSpringProperties.java index f29f44dc71..c8aee779fa 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/SessionsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/VersionsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/VersionsSpringAutoConfiguration.java index b3b39b6a9a..fc39b706fd 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/VersionsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/VersionsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected VersionsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/VersionsSpringProperties.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/VersionsSpringProperties.java index b25f68b722..34acbcfd36 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/VersionsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/VersionsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/package-info.java index 3b5a73d79d..3df340ab02 100644 --- a/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-dialogflow-spring-starter/src/main/java/com/google/cloud/dialogflow/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/DlpServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/DlpServiceSpringAutoConfiguration.java index c1681213fd..031920c27f 100644 --- a/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/DlpServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/DlpServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected DlpServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/DlpServiceSpringProperties.java b/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/DlpServiceSpringProperties.java index 63d22f2658..25b287d127 100644 --- a/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/DlpServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/DlpServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/package-info.java index 8fb105c7ce..ef32be4c96 100644 --- a/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-dlp-spring-starter/src/main/java/com/google/cloud/dlp/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/DataMigrationServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/DataMigrationServiceSpringAutoConfiguration.java index 382ac7275a..5e210b20c5 100644 --- a/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/DataMigrationServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/DataMigrationServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected DataMigrationServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/DataMigrationServiceSpringProperties.java b/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/DataMigrationServiceSpringProperties.java index 39aabd1265..2a6e1aa377 100644 --- a/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/DataMigrationServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/DataMigrationServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/package-info.java index ab17c9344a..b19fac3b33 100644 --- a/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-dms-spring-starter/src/main/java/com/google/cloud/clouddms/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/DocumentProcessorServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/DocumentProcessorServiceSpringAutoConfiguration.java index e7f89f262a..8a22d526f1 100644 --- a/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/DocumentProcessorServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/DocumentProcessorServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected DocumentProcessorServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/DocumentProcessorServiceSpringProperties.java b/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/DocumentProcessorServiceSpringProperties.java index c02aff5264..dd86cb7a4c 100644 --- a/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/DocumentProcessorServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/DocumentProcessorServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/package-info.java index 5743d75ea2..c991ccd7ab 100644 --- a/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-document-ai-spring-starter/src/main/java/com/google/cloud/documentai/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/DomainsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/DomainsSpringAutoConfiguration.java index 02c7ede874..e723c97374 100644 --- a/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/DomainsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/DomainsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected DomainsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/DomainsSpringProperties.java b/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/DomainsSpringProperties.java index e419118f38..e3d853a2ad 100644 --- a/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/DomainsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/DomainsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/package-info.java index 14c1b9b71a..b4b18a566e 100644 --- a/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-domains-spring-starter/src/main/java/com/google/cloud/domains/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/EssentialContactsServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/EssentialContactsServiceSpringAutoConfiguration.java index a3242663af..9cff8ab181 100644 --- a/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/EssentialContactsServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/EssentialContactsServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected EssentialContactsServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/EssentialContactsServiceSpringProperties.java b/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/EssentialContactsServiceSpringProperties.java index a56a378906..32b7ee65d4 100644 --- a/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/EssentialContactsServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/EssentialContactsServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/package-info.java index 45907cd5f6..8b908bf875 100644 --- a/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-essential-contacts-spring-starter/src/main/java/com/google/cloud/essentialcontacts/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/EventarcSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/EventarcSpringAutoConfiguration.java index 35feffac61..372bc22ee9 100644 --- a/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/EventarcSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/EventarcSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected EventarcSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/EventarcSpringProperties.java b/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/EventarcSpringProperties.java index 94787f0a51..011a3360f7 100644 --- a/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/EventarcSpringProperties.java +++ b/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/EventarcSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/package-info.java index f3150758e1..83d13c4ad6 100644 --- a/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-eventarc-spring-starter/src/main/java/com/google/cloud/eventarc/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/CloudFilestoreManagerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/CloudFilestoreManagerSpringAutoConfiguration.java index 490408b51c..9bfc9923df 100644 --- a/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/CloudFilestoreManagerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/CloudFilestoreManagerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected CloudFilestoreManagerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/CloudFilestoreManagerSpringProperties.java b/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/CloudFilestoreManagerSpringProperties.java index 6a4e46dc95..c9e632a42d 100644 --- a/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/CloudFilestoreManagerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/CloudFilestoreManagerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/package-info.java index 02ed3ea8bc..c1bd645dad 100644 --- a/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-filestore-spring-starter/src/main/java/com/google/cloud/filestore/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/FunctionServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/FunctionServiceSpringAutoConfiguration.java index acd2ed9ab8..38dd67a841 100644 --- a/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/FunctionServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/FunctionServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected FunctionServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/FunctionServiceSpringProperties.java b/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/FunctionServiceSpringProperties.java index 729911eea3..64abe37c6b 100644 --- a/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/FunctionServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/FunctionServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/package-info.java index 88609c6c95..ec4ff8f583 100644 --- a/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-functions-spring-starter/src/main/java/com/google/cloud/functions/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerClustersServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerClustersServiceSpringAutoConfiguration.java index fd8819d553..e38476c8aa 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerClustersServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerClustersServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected GameServerClustersServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerClustersServiceSpringProperties.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerClustersServiceSpringProperties.java index 5392d55859..781ea34eae 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerClustersServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerClustersServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerConfigsServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerConfigsServiceSpringAutoConfiguration.java index f2cf366623..7e822b9880 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerConfigsServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerConfigsServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected GameServerConfigsServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerConfigsServiceSpringProperties.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerConfigsServiceSpringProperties.java index 2bbdd12f0d..04563c3ddf 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerConfigsServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerConfigsServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerDeploymentsServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerDeploymentsServiceSpringAutoConfiguration.java index bbd2239670..9ebbf60367 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerDeploymentsServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerDeploymentsServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected GameServerDeploymentsServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerDeploymentsServiceSpringProperties.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerDeploymentsServiceSpringProperties.java index 3951031dc6..9ca3c80dd0 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerDeploymentsServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/GameServerDeploymentsServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/RealmsServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/RealmsServiceSpringAutoConfiguration.java index d55d0e50f7..e2b62ab8ab 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/RealmsServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/RealmsServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected RealmsServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/RealmsServiceSpringProperties.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/RealmsServiceSpringProperties.java index ac1ae5a3e5..fc82c54d3e 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/RealmsServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/RealmsServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/package-info.java index 5240e35245..9bfd208083 100644 --- a/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-game-servers-spring-starter/src/main/java/com/google/cloud/gaming/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/GkeHubSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/GkeHubSpringAutoConfiguration.java index 25a768ab95..564ecab937 100644 --- a/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/GkeHubSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/GkeHubSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected GkeHubSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/GkeHubSpringProperties.java b/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/GkeHubSpringProperties.java index 9dd06aff4e..ad8565f520 100644 --- a/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/GkeHubSpringProperties.java +++ b/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/GkeHubSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/package-info.java index 37e92997f0..5899978d47 100644 --- a/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-gkehub-spring-starter/src/main/java/com/google/cloud/gkehub/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/GSuiteAddOnsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/GSuiteAddOnsSpringAutoConfiguration.java index 0577feb0ff..391e420fd7 100644 --- a/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/GSuiteAddOnsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/GSuiteAddOnsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected GSuiteAddOnsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/GSuiteAddOnsSpringProperties.java b/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/GSuiteAddOnsSpringProperties.java index ddcee99ca7..f77a923d40 100644 --- a/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/GSuiteAddOnsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/GSuiteAddOnsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/package-info.java index 9d3d311026..d3c57bc74c 100644 --- a/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-gsuite-addons-spring-starter/src/main/java/com/google/cloud/gsuiteaddons/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/IAMCredentialsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/IAMCredentialsSpringAutoConfiguration.java index b458d7e23a..63a63640a2 100644 --- a/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/IAMCredentialsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/IAMCredentialsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected IAMCredentialsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/IAMCredentialsSpringProperties.java b/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/IAMCredentialsSpringProperties.java index d4335dbf61..aa7ca4d098 100644 --- a/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/IAMCredentialsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/IAMCredentialsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/package-info.java index 01f5d5dd79..4f0f79c857 100644 --- a/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-iamcredentials-spring-starter/src/main/java/com/google/cloud/iam/credentials/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/IDSSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/IDSSpringAutoConfiguration.java index bc6b757f57..91bcbcfefc 100644 --- a/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/IDSSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/IDSSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected IDSSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/IDSSpringProperties.java b/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/IDSSpringProperties.java index e68c2a4be7..9467e8861b 100644 --- a/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/IDSSpringProperties.java +++ b/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/IDSSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/package-info.java index 59bf7f698e..a2138dfbd1 100644 --- a/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-ids-spring-starter/src/main/java/com/google/cloud/ids/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/DeviceManagerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/DeviceManagerSpringAutoConfiguration.java index 0bff94892a..f1a93b1b30 100644 --- a/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/DeviceManagerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/DeviceManagerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected DeviceManagerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/DeviceManagerSpringProperties.java b/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/DeviceManagerSpringProperties.java index 28b05a4246..a8897f3790 100644 --- a/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/DeviceManagerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/DeviceManagerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/package-info.java index dbb5f115fa..f07830dfed 100644 --- a/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-iot-spring-starter/src/main/java/com/google/cloud/iot/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java index 7607eb4343..f65684ef5b 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected LanguageServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java index 2dc3ba178f..3c9dbc58d7 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/LanguageServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/package-info.java index b7f4ba555b..8c53832a3e 100644 --- a/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-language-spring-starter/src/main/java/com/google/cloud/language/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/ManagedIdentitiesServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/ManagedIdentitiesServiceSpringAutoConfiguration.java index 7d3c6b0e68..a0146a2161 100644 --- a/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/ManagedIdentitiesServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/ManagedIdentitiesServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected ManagedIdentitiesServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/ManagedIdentitiesServiceSpringProperties.java b/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/ManagedIdentitiesServiceSpringProperties.java index a824920ea6..d88c86f739 100644 --- a/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/ManagedIdentitiesServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/ManagedIdentitiesServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/package-info.java index bdffd589a3..8695c92fab 100644 --- a/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-managed-identities-spring-starter/src/main/java/com/google/cloud/managedidentities/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/CloudMemcacheSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/CloudMemcacheSpringAutoConfiguration.java index 6b50b8a4c2..75bc53adb5 100644 --- a/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/CloudMemcacheSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/CloudMemcacheSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CloudMemcacheSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/CloudMemcacheSpringProperties.java b/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/CloudMemcacheSpringProperties.java index fe0d3bdfe3..c067185b44 100644 --- a/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/CloudMemcacheSpringProperties.java +++ b/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/CloudMemcacheSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/package-info.java index c294894029..a3bd801368 100644 --- a/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-memcache-spring-starter/src/main/java/com/google/cloud/memcache/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/DashboardsServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/DashboardsServiceSpringAutoConfiguration.java index 4bcb90e771..ca28be9e4a 100644 --- a/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/DashboardsServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/DashboardsServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected DashboardsServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/DashboardsServiceSpringProperties.java b/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/DashboardsServiceSpringProperties.java index f6b3c1d7ee..850f56cdcc 100644 --- a/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/DashboardsServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/DashboardsServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/package-info.java index 4269255458..0dbb6bdacf 100644 --- a/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-monitoring-dashboard-spring-starter/src/main/java/com/google/cloud/monitoring/dashboard/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/ReachabilityServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/ReachabilityServiceSpringAutoConfiguration.java index c2efa85e47..a9fa2a46b0 100644 --- a/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/ReachabilityServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/ReachabilityServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ReachabilityServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/ReachabilityServiceSpringProperties.java b/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/ReachabilityServiceSpringProperties.java index 1c835e9b75..dba261330d 100644 --- a/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/ReachabilityServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/ReachabilityServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/package-info.java index 14b45e87df..360eb7fc7e 100644 --- a/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-network-management-spring-starter/src/main/java/com/google/cloud/networkmanagement/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/HubServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/HubServiceSpringAutoConfiguration.java index abf0daf185..d831c3981d 100644 --- a/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/HubServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/HubServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected HubServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/HubServiceSpringProperties.java b/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/HubServiceSpringProperties.java index 756a45bf54..e8d3295aca 100644 --- a/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/HubServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/HubServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/package-info.java index 1ab80a5b73..e1cf306ad2 100644 --- a/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-networkconnectivity-spring-starter/src/main/java/com/google/cloud/networkconnectivity/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/ManagedNotebookServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/ManagedNotebookServiceSpringAutoConfiguration.java index a8fcb98f8a..c0b74a0462 100644 --- a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/ManagedNotebookServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/ManagedNotebookServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected ManagedNotebookServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/ManagedNotebookServiceSpringProperties.java b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/ManagedNotebookServiceSpringProperties.java index cfac94184d..6cfc63095d 100644 --- a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/ManagedNotebookServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/ManagedNotebookServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/NotebookServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/NotebookServiceSpringAutoConfiguration.java index d298a869a6..901091364b 100644 --- a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/NotebookServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/NotebookServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected NotebookServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/NotebookServiceSpringProperties.java b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/NotebookServiceSpringProperties.java index a5a99c2aea..bf42b4f61e 100644 --- a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/NotebookServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/NotebookServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/package-info.java index 8fa73cba30..c8dab6df2f 100644 --- a/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-notebooks-spring-starter/src/main/java/com/google/cloud/notebooks/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/FleetRoutingSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/FleetRoutingSpringAutoConfiguration.java index 9806cff105..cef057f981 100644 --- a/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/FleetRoutingSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/FleetRoutingSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected FleetRoutingSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/FleetRoutingSpringProperties.java b/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/FleetRoutingSpringProperties.java index 55ef5b2441..511534b253 100644 --- a/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/FleetRoutingSpringProperties.java +++ b/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/FleetRoutingSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/package-info.java index 85f1d496a2..b695777116 100644 --- a/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-optimization-spring-starter/src/main/java/com/google/cloud/optimization/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/EnvironmentsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/EnvironmentsSpringAutoConfiguration.java index 2aa5fb4f30..834ea63926 100644 --- a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/EnvironmentsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/EnvironmentsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected EnvironmentsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/EnvironmentsSpringProperties.java b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/EnvironmentsSpringProperties.java index f71a571dad..3536b6a9ed 100644 --- a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/EnvironmentsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/EnvironmentsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/ImageVersionsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/ImageVersionsSpringAutoConfiguration.java index 3278fdc222..79bd4ff37f 100644 --- a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/ImageVersionsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/ImageVersionsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ImageVersionsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/ImageVersionsSpringProperties.java b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/ImageVersionsSpringProperties.java index d2c4180479..9322feb8c5 100644 --- a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/ImageVersionsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/ImageVersionsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/package-info.java index 19220adb3a..9a20161c27 100644 --- a/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-orchestration-airflow-spring-starter/src/main/java/com/google/cloud/orchestration/airflow/service/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/OrgPolicySpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/OrgPolicySpringAutoConfiguration.java index 97cd80695b..d2c736a522 100644 --- a/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/OrgPolicySpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/OrgPolicySpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected OrgPolicySpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/OrgPolicySpringProperties.java b/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/OrgPolicySpringProperties.java index 592df0275e..445df2fef4 100644 --- a/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/OrgPolicySpringProperties.java +++ b/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/OrgPolicySpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/package-info.java index 57cace2fea..3a9909dfb9 100644 --- a/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-orgpolicy-spring-starter/src/main/java/com/google/cloud/orgpolicy/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigServiceSpringAutoConfiguration.java index 16f8ee7150..d594446cb1 100644 --- a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected OsConfigServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigServiceSpringProperties.java b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigServiceSpringProperties.java index 224c329774..f282145019 100644 --- a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigZonalServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigZonalServiceSpringAutoConfiguration.java index 708331f37d..18998dbf4f 100644 --- a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigZonalServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigZonalServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected OsConfigZonalServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigZonalServiceSpringProperties.java b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigZonalServiceSpringProperties.java index fc064b0f6a..b10fd25cac 100644 --- a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigZonalServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/OsConfigZonalServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/package-info.java index a1856e2048..550ed034c4 100644 --- a/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-os-config-spring-starter/src/main/java/com/google/cloud/osconfig/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/OsLoginServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/OsLoginServiceSpringAutoConfiguration.java index d895e5cb3e..78be61f14b 100644 --- a/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/OsLoginServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/OsLoginServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected OsLoginServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/OsLoginServiceSpringProperties.java b/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/OsLoginServiceSpringProperties.java index 0b4a3570d8..af59f072dd 100644 --- a/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/OsLoginServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/OsLoginServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/package-info.java index ba7d12213a..4733de1ab3 100644 --- a/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-os-login-spring-starter/src/main/java/com/google/cloud/oslogin/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/IamCheckerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/IamCheckerSpringAutoConfiguration.java index affc9cc06a..1002350c26 100644 --- a/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/IamCheckerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/IamCheckerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected IamCheckerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/IamCheckerSpringProperties.java b/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/IamCheckerSpringProperties.java index 0f945cd34b..8096acde3c 100644 --- a/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/IamCheckerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/IamCheckerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/package-info.java index caaed3f6cf..7fab1dad7c 100644 --- a/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-policy-troubleshooter-spring-starter/src/main/java/com/google/cloud/policytroubleshooter/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/ProfilerServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/ProfilerServiceSpringAutoConfiguration.java index 18e72f6ce8..50660052b9 100644 --- a/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/ProfilerServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/ProfilerServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ProfilerServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/ProfilerServiceSpringProperties.java b/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/ProfilerServiceSpringProperties.java index 3b2f571ec0..f4bc3d6e0c 100644 --- a/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/ProfilerServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/ProfilerServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/package-info.java index 00e2e19f35..2fa10ef36e 100644 --- a/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-profiler-spring-starter/src/main/java/com/google/devtools/cloudprofiler/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/RecaptchaEnterpriseServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/RecaptchaEnterpriseServiceSpringAutoConfiguration.java index 61142a5731..ea6e4ead95 100644 --- a/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/RecaptchaEnterpriseServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/RecaptchaEnterpriseServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected RecaptchaEnterpriseServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/RecaptchaEnterpriseServiceSpringProperties.java b/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/RecaptchaEnterpriseServiceSpringProperties.java index cddcd6931e..9b1bf3c389 100644 --- a/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/RecaptchaEnterpriseServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/RecaptchaEnterpriseServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/package-info.java index 441912903e..085b6e3dd3 100644 --- a/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-recaptchaenterprise-spring-starter/src/main/java/com/google/cloud/recaptchaenterprise/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/RecommenderSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/RecommenderSpringAutoConfiguration.java index 8255f04cbd..59feb4dff8 100644 --- a/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/RecommenderSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/RecommenderSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected RecommenderSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/RecommenderSpringProperties.java b/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/RecommenderSpringProperties.java index f36b339705..6d9decb155 100644 --- a/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/RecommenderSpringProperties.java +++ b/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/RecommenderSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/package-info.java index ffcb9c4f67..688827c9ce 100644 --- a/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-recommender-spring-starter/src/main/java/com/google/cloud/recommender/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/CloudRedisSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/CloudRedisSpringAutoConfiguration.java index e1d0b2143a..a441cd58eb 100644 --- a/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/CloudRedisSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/CloudRedisSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CloudRedisSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/CloudRedisSpringProperties.java b/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/CloudRedisSpringProperties.java index 100f98f630..1ef417404d 100644 --- a/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/CloudRedisSpringProperties.java +++ b/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/CloudRedisSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/package-info.java index 78dbf2d25e..d190524b4a 100644 --- a/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-redis-spring-starter/src/main/java/com/google/cloud/redis/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/ResourceSettingsServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/ResourceSettingsServiceSpringAutoConfiguration.java index 05f864a442..b5e2a49a95 100644 --- a/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/ResourceSettingsServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/ResourceSettingsServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected ResourceSettingsServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/ResourceSettingsServiceSpringProperties.java b/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/ResourceSettingsServiceSpringProperties.java index 1aad77a257..b476a481f1 100644 --- a/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/ResourceSettingsServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/ResourceSettingsServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/package-info.java index 06619ac15e..ae74a7fb4b 100644 --- a/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-resource-settings-spring-starter/src/main/java/com/google/cloud/resourcesettings/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CatalogServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CatalogServiceSpringAutoConfiguration.java index bc2e9462e4..dcdf5aaa98 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CatalogServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CatalogServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CatalogServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CatalogServiceSpringProperties.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CatalogServiceSpringProperties.java index ff13013878..e759031585 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CatalogServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CatalogServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CompletionServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CompletionServiceSpringAutoConfiguration.java index 0fe8a00e33..89720907c1 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CompletionServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CompletionServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected CompletionServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CompletionServiceSpringProperties.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CompletionServiceSpringProperties.java index df6ff3c3fd..06ed7bc1b2 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CompletionServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/CompletionServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ControlServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ControlServiceSpringAutoConfiguration.java index 51f10ed0bc..da5787c88f 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ControlServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ControlServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ControlServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ControlServiceSpringProperties.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ControlServiceSpringProperties.java index b87e0793a9..2dac94ac5c 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ControlServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ControlServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/PredictionServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/PredictionServiceSpringAutoConfiguration.java index c5b638dd2b..1c73eeb4ca 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/PredictionServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/PredictionServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected PredictionServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/PredictionServiceSpringProperties.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/PredictionServiceSpringProperties.java index 7bf9c93d25..c911104237 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/PredictionServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/PredictionServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ProductServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ProductServiceSpringAutoConfiguration.java index 54187394b6..899b7249b5 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ProductServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ProductServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ProductServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ProductServiceSpringProperties.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ProductServiceSpringProperties.java index 73c33431d8..55228a9d01 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ProductServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ProductServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/SearchServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/SearchServiceSpringAutoConfiguration.java index 00d11a7294..c06bc90b0f 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/SearchServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/SearchServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected SearchServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/SearchServiceSpringProperties.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/SearchServiceSpringProperties.java index 33ab8f6e5a..60ef667bff 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/SearchServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/SearchServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ServingConfigServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ServingConfigServiceSpringAutoConfiguration.java index db11ec7ea0..e811bc2f9a 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ServingConfigServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ServingConfigServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected ServingConfigServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ServingConfigServiceSpringProperties.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ServingConfigServiceSpringProperties.java index 6218b2125c..5ecc40a8cd 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ServingConfigServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/ServingConfigServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/UserEventServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/UserEventServiceSpringAutoConfiguration.java index 1e2852d330..08df58651a 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/UserEventServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/UserEventServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected UserEventServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/UserEventServiceSpringProperties.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/UserEventServiceSpringProperties.java index a3be6326e4..5e604359fb 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/UserEventServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/UserEventServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/package-info.java index f18483a754..23d64dbac3 100644 --- a/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-retail-spring-starter/src/main/java/com/google/cloud/retail/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/CloudSchedulerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/CloudSchedulerSpringAutoConfiguration.java index 0a66a06234..70f7bd2016 100644 --- a/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/CloudSchedulerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/CloudSchedulerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CloudSchedulerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/CloudSchedulerSpringProperties.java b/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/CloudSchedulerSpringProperties.java index d94e0020ba..865e775db5 100644 --- a/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/CloudSchedulerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/CloudSchedulerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/package-info.java index f3789d2c21..43f07fb01d 100644 --- a/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-scheduler-spring-starter/src/main/java/com/google/cloud/scheduler/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/CertificateAuthorityServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/CertificateAuthorityServiceSpringAutoConfiguration.java index 8b8df15c4a..0ac2928ff2 100644 --- a/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/CertificateAuthorityServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/CertificateAuthorityServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected CertificateAuthorityServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/CertificateAuthorityServiceSpringProperties.java b/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/CertificateAuthorityServiceSpringProperties.java index ec13dc2a40..89cc46734f 100644 --- a/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/CertificateAuthorityServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/CertificateAuthorityServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/package-info.java index de44966b8c..067aa9e1f5 100644 --- a/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-security-private-ca-spring-starter/src/main/java/com/google/cloud/security/privateca/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/SecurityCenterSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/SecurityCenterSpringAutoConfiguration.java index 914b9ecb28..a223042912 100644 --- a/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/SecurityCenterSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/SecurityCenterSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected SecurityCenterSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/SecurityCenterSpringProperties.java b/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/SecurityCenterSpringProperties.java index a08f423ca0..3e8f00667e 100644 --- a/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/SecurityCenterSpringProperties.java +++ b/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/SecurityCenterSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/package-info.java index b44040c87c..d7787b54a1 100644 --- a/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-securitycenter-spring-starter/src/main/java/com/google/cloud/securitycenter/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/ServiceControllerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/ServiceControllerSpringAutoConfiguration.java index b541ebc3d5..36e3d00227 100644 --- a/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/ServiceControllerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/ServiceControllerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected ServiceControllerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/ServiceControllerSpringProperties.java b/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/ServiceControllerSpringProperties.java index 99213f45de..a459950221 100644 --- a/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/ServiceControllerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/ServiceControllerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/package-info.java index 4e02ebadfa..eb3bc4cbfd 100644 --- a/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-service-control-spring-starter/src/main/java/com/google/api/servicecontrol/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/ServiceManagerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/ServiceManagerSpringAutoConfiguration.java index 868eadfbcd..ca71c21f3e 100644 --- a/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/ServiceManagerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/ServiceManagerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ServiceManagerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/ServiceManagerSpringProperties.java b/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/ServiceManagerSpringProperties.java index ed4042c2c2..ebfdc48254 100644 --- a/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/ServiceManagerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/ServiceManagerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/package-info.java index 0496c584b2..62f0d404bb 100644 --- a/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-service-management-spring-starter/src/main/java/com/google/cloud/api/servicemanagement/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/ServiceUsageSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/ServiceUsageSpringAutoConfiguration.java index cc43b49a17..c6743f739f 100644 --- a/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/ServiceUsageSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/ServiceUsageSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ServiceUsageSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/ServiceUsageSpringProperties.java b/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/ServiceUsageSpringProperties.java index e955dcc94c..e0c74131aa 100644 --- a/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/ServiceUsageSpringProperties.java +++ b/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/ServiceUsageSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/package-info.java index d8b8a9004a..0d25050c73 100644 --- a/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-service-usage-spring-starter/src/main/java/com/google/api/serviceusage/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/LookupServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/LookupServiceSpringAutoConfiguration.java index 2a205c6e13..f7c2607bfc 100644 --- a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/LookupServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/LookupServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected LookupServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/LookupServiceSpringProperties.java b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/LookupServiceSpringProperties.java index fabd382f1a..9792438c20 100644 --- a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/LookupServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/LookupServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/RegistrationServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/RegistrationServiceSpringAutoConfiguration.java index d8157de723..c06101f4c3 100644 --- a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/RegistrationServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/RegistrationServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected RegistrationServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/RegistrationServiceSpringProperties.java b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/RegistrationServiceSpringProperties.java index a740bc47c6..72c05357c8 100644 --- a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/RegistrationServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/RegistrationServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/package-info.java index ad036fdb94..e96b0b7867 100644 --- a/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-servicedirectory-spring-starter/src/main/java/com/google/cloud/servicedirectory/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/CloudShellServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/CloudShellServiceSpringAutoConfiguration.java index 7786e96425..8f3c6ab35e 100644 --- a/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/CloudShellServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/CloudShellServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected CloudShellServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/CloudShellServiceSpringProperties.java b/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/CloudShellServiceSpringProperties.java index 148b979474..704f56464a 100644 --- a/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/CloudShellServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/CloudShellServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/package-info.java index 668506b8d8..dac4250744 100644 --- a/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-shell-spring-starter/src/main/java/com/google/cloud/shell/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/SpeechSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/SpeechSpringAutoConfiguration.java index 3e02bbf89c..45becff3ac 100644 --- a/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/SpeechSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/SpeechSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected SpeechSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/SpeechSpringProperties.java b/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/SpeechSpringProperties.java index 48a83677fb..632504412e 100644 --- a/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/SpeechSpringProperties.java +++ b/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/SpeechSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/package-info.java index ec953a7807..aac5b66245 100644 --- a/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-speech-spring-starter/src/main/java/com/google/cloud/speech/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/StorageTransferServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/StorageTransferServiceSpringAutoConfiguration.java index bd997140c2..5f624e5646 100644 --- a/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/StorageTransferServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/StorageTransferServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected StorageTransferServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/StorageTransferServiceSpringProperties.java b/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/StorageTransferServiceSpringProperties.java index 52c90d50ac..68305a2372 100644 --- a/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/StorageTransferServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/StorageTransferServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/package-info.java b/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/package-info.java index 3868dd41d8..0f8adefa6a 100644 --- a/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-storage-transfer-spring-starter/src/main/java/com/google/storagetransfer/v1/proto/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompanyServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompanyServiceSpringAutoConfiguration.java index ed89881db7..8c1b2dd7bc 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompanyServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompanyServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CompanyServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompanyServiceSpringProperties.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompanyServiceSpringProperties.java index 3435d32ef1..4e0ebee4b6 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompanyServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompanyServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompletionSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompletionSpringAutoConfiguration.java index cac09134b8..3e64194998 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompletionSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompletionSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CompletionSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompletionSpringProperties.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompletionSpringProperties.java index d46de2eabf..be18c813ab 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompletionSpringProperties.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/CompletionSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/EventServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/EventServiceSpringAutoConfiguration.java index 6309c8b1bb..e4170ea788 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/EventServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/EventServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected EventServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/EventServiceSpringProperties.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/EventServiceSpringProperties.java index 97ce805311..73168c0368 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/EventServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/EventServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/JobServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/JobServiceSpringAutoConfiguration.java index 72c1eab54a..63b6cf8484 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/JobServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/JobServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected JobServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/JobServiceSpringProperties.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/JobServiceSpringProperties.java index 34d14a5491..807b830940 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/JobServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/JobServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/TenantServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/TenantServiceSpringAutoConfiguration.java index d8d3804735..589e6e97c6 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/TenantServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/TenantServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected TenantServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/TenantServiceSpringProperties.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/TenantServiceSpringProperties.java index ae518b8504..6ed37e9429 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/TenantServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/TenantServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/package-info.java b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/package-info.java index c11e053162..670fdf2e28 100644 --- a/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-talent-spring-starter/src/main/java/com/google/cloud/talent/v4/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/CloudTasksSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/CloudTasksSpringAutoConfiguration.java index d9d6a4c234..f51957bdb0 100644 --- a/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/CloudTasksSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/CloudTasksSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected CloudTasksSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/CloudTasksSpringProperties.java b/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/CloudTasksSpringProperties.java index 5b6ce2efc4..53a9463890 100644 --- a/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/CloudTasksSpringProperties.java +++ b/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/CloudTasksSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/package-info.java index f03145ea4b..f98d317b1b 100644 --- a/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-tasks-spring-starter/src/main/java/com/google/cloud/tasks/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechLongAudioSynthesizeSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechLongAudioSynthesizeSpringAutoConfiguration.java index 481dbe7620..8d91bbee55 100644 --- a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechLongAudioSynthesizeSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechLongAudioSynthesizeSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected TextToSpeechLongAudioSynthesizeSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechLongAudioSynthesizeSpringProperties.java b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechLongAudioSynthesizeSpringProperties.java index af449903cc..f8a9923560 100644 --- a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechLongAudioSynthesizeSpringProperties.java +++ b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechLongAudioSynthesizeSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechSpringAutoConfiguration.java index 0ef0d68c23..75441139c1 100644 --- a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected TextToSpeechSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechSpringProperties.java b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechSpringProperties.java index edfc9e9b55..09233221f5 100644 --- a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechSpringProperties.java +++ b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/TextToSpeechSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/package-info.java index a553b12030..039b4db383 100644 --- a/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-texttospeech-spring-starter/src/main/java/com/google/cloud/texttospeech/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/TpuSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/TpuSpringAutoConfiguration.java index 34b7a7015b..ea298467db 100644 --- a/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/TpuSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/TpuSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected TpuSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/TpuSpringProperties.java b/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/TpuSpringProperties.java index d89655095c..b867f4c1fc 100644 --- a/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/TpuSpringProperties.java +++ b/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/TpuSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/package-info.java index 0afff4e0d2..090ee439b2 100644 --- a/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-tpu-spring-starter/src/main/java/com/google/cloud/tpu/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/TraceServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/TraceServiceSpringAutoConfiguration.java index 4dac5ed1fe..0ddf7a3783 100644 --- a/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/TraceServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/TraceServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected TraceServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/TraceServiceSpringProperties.java b/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/TraceServiceSpringProperties.java index 9347287ed2..5dda81e811 100644 --- a/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/TraceServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/TraceServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/package-info.java b/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/package-info.java index 7d1aa3e0ab..36c88bcf96 100644 --- a/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-trace-spring-starter/src/main/java/com/google/cloud/trace/v2/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/VideoIntelligenceServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/VideoIntelligenceServiceSpringAutoConfiguration.java index ab68109db3..3714d9e65b 100644 --- a/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/VideoIntelligenceServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/VideoIntelligenceServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected VideoIntelligenceServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/VideoIntelligenceServiceSpringProperties.java b/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/VideoIntelligenceServiceSpringProperties.java index 02a587ad5a..615e4aae00 100644 --- a/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/VideoIntelligenceServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/VideoIntelligenceServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/package-info.java index 9c084910f1..825a31731d 100644 --- a/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-video-intelligence-spring-starter/src/main/java/com/google/cloud/videointelligence/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/TranscoderServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/TranscoderServiceSpringAutoConfiguration.java index 8e039c116b..7b80042255 100644 --- a/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/TranscoderServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/TranscoderServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected TranscoderServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/TranscoderServiceSpringProperties.java b/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/TranscoderServiceSpringProperties.java index 6fdd8cba3a..0abf04dcba 100644 --- a/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/TranscoderServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/TranscoderServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/package-info.java index 88c090beea..cdd90090b7 100644 --- a/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-video-transcoder-spring-starter/src/main/java/com/google/cloud/video/transcoder/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/VmMigrationSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/VmMigrationSpringAutoConfiguration.java index ce5cf5e258..84c983dbcb 100644 --- a/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/VmMigrationSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/VmMigrationSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected VmMigrationSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/VmMigrationSpringProperties.java b/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/VmMigrationSpringProperties.java index e21bebeafa..9aefdb5e31 100644 --- a/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/VmMigrationSpringProperties.java +++ b/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/VmMigrationSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/package-info.java index 5644969cf6..6d56f6c267 100644 --- a/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-vmmigration-spring-starter/src/main/java/com/google/cloud/vmmigration/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/VpcAccessServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/VpcAccessServiceSpringAutoConfiguration.java index 7d50a43065..ed5ab28529 100644 --- a/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/VpcAccessServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/VpcAccessServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected VpcAccessServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/VpcAccessServiceSpringProperties.java b/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/VpcAccessServiceSpringProperties.java index 6b3a9dee28..0e3e1fe7ef 100644 --- a/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/VpcAccessServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/VpcAccessServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/package-info.java index 951175d531..3236be05cc 100644 --- a/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-vpcaccess-spring-starter/src/main/java/com/google/cloud/vpcaccess/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/WebRiskServiceSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/WebRiskServiceSpringAutoConfiguration.java index 83acba491b..13845beb1a 100644 --- a/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/WebRiskServiceSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/WebRiskServiceSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected WebRiskServiceSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/WebRiskServiceSpringProperties.java b/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/WebRiskServiceSpringProperties.java index 2f794e6d97..3256e8986a 100644 --- a/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/WebRiskServiceSpringProperties.java +++ b/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/WebRiskServiceSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/package-info.java index 81edc06544..a0ceefca6f 100644 --- a/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-webrisk-spring-starter/src/main/java/com/google/cloud/webrisk/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/WebSecurityScannerSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/WebSecurityScannerSpringAutoConfiguration.java index 798f50de58..9baacb2398 100644 --- a/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/WebSecurityScannerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/WebSecurityScannerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,8 +87,10 @@ protected WebSecurityScannerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/WebSecurityScannerSpringProperties.java b/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/WebSecurityScannerSpringProperties.java index ca4686a7a9..79713bf06c 100644 --- a/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/WebSecurityScannerSpringProperties.java +++ b/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/WebSecurityScannerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/package-info.java index deb1c13856..f538864316 100644 --- a/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-websecurityscanner-spring-starter/src/main/java/com/google/cloud/websecurityscanner/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/ExecutionsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/ExecutionsSpringAutoConfiguration.java index 13aadec72b..6cdc6c7d02 100644 --- a/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/ExecutionsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/ExecutionsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected ExecutionsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/ExecutionsSpringProperties.java b/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/ExecutionsSpringProperties.java index 901e63a3a1..e3e88dbae0 100644 --- a/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/ExecutionsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/ExecutionsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/package-info.java index 95ee96fe34..25b33907c4 100644 --- a/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-workflow-executions-spring-starter/src/main/java/com/google/cloud/workflows/executions/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/WorkflowsSpringAutoConfiguration.java b/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/WorkflowsSpringAutoConfiguration.java index b660be7d75..9f7697d5ed 100644 --- a/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/WorkflowsSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/WorkflowsSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,8 +86,10 @@ protected WorkflowsSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/WorkflowsSpringProperties.java b/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/WorkflowsSpringProperties.java index 0a27e4de13..e0f11009f3 100644 --- a/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/WorkflowsSpringProperties.java +++ b/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/WorkflowsSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/package-info.java b/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/package-info.java index a0319d62e7..d54c86ad3f 100644 --- a/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/package-info.java +++ b/spring-cloud-previews/google-cloud-workflows-spring-starter/src/main/java/com/google/cloud/workflows/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/IAMSpringAutoConfiguration.java b/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/IAMSpringAutoConfiguration.java index 012c443bb9..fb0ca9c1fc 100644 --- a/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/IAMSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/IAMSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,8 +84,10 @@ protected IAMSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/IAMSpringProperties.java b/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/IAMSpringProperties.java index e49c2c3454..e6871e00f1 100644 --- a/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/IAMSpringProperties.java +++ b/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/IAMSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/package-info.java b/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/package-info.java index 1edce55dd7..baedbc511d 100644 --- a/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/package-info.java +++ b/spring-cloud-previews/google-iam-admin-spring-starter/src/main/java/com/google/cloud/iam/admin/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/AccessContextManagerSpringAutoConfiguration.java b/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/AccessContextManagerSpringAutoConfiguration.java index e094a913f4..c9ec00a311 100644 --- a/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/AccessContextManagerSpringAutoConfiguration.java +++ b/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/AccessContextManagerSpringAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -88,8 +88,10 @@ protected AccessContextManagerSpringAutoConfiguration( } /** - * Provides a default transport channel provider bean. The default is gRPC and will default to it - * unless the useRest option is supported and provided to use HTTP transport instead + * Provides a default transport channel provider bean, corresponding to the client library's + * default transport channel provider. If the library supports both GRPC and REST transport, and + * the useRest property is configured, the HTTP/JSON transport provider will be used instead of + * GRPC. * * @return a default transport channel provider. */ diff --git a/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/AccessContextManagerSpringProperties.java b/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/AccessContextManagerSpringProperties.java index df44864957..011f545997 100644 --- a/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/AccessContextManagerSpringProperties.java +++ b/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/AccessContextManagerSpringProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/package-info.java b/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/package-info.java index 2758b1fd14..3a5fb9ccd9 100644 --- a/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/package-info.java +++ b/spring-cloud-previews/google-identity-accesscontextmanager-spring-starter/src/main/java/com/google/identity/accesscontextmanager/v1/spring/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-cloud-previews/pom.xml b/spring-cloud-previews/pom.xml index 3e37cfe543..ab801a4bb4 100644 --- a/spring-cloud-previews/pom.xml +++ b/spring-cloud-previews/pom.xml @@ -82,6 +82,7 @@ google-cloud-containeranalysis-spring-starter google-cloud-container-spring-starter google-cloud-contact-center-insights-spring-starter + google-cloud-compute-spring-starter google-cloud-build-spring-starter google-cloud-channel-spring-starter google-cloud-binary-authorization-spring-starter