14
14
* limitations under the License.
15
15
*/
16
16
17
- package com .google .iam . v2 .spring ;
17
+ package com .google .cloud . compute . v1 .spring ;
18
18
19
19
import com .google .api .core .BetaApi ;
20
20
import com .google .api .gax .core .CredentialsProvider ;
21
21
import com .google .api .gax .core .ExecutorProvider ;
22
22
import com .google .api .gax .retrying .RetrySettings ;
23
23
import com .google .api .gax .rpc .HeaderProvider ;
24
24
import com .google .api .gax .rpc .TransportChannelProvider ;
25
+ import com .google .cloud .compute .v1 .ReservationBlocksClient ;
26
+ import com .google .cloud .compute .v1 .ReservationBlocksSettings ;
25
27
import com .google .cloud .spring .autoconfigure .core .GcpContextAutoConfiguration ;
26
28
import com .google .cloud .spring .core .DefaultCredentialsProvider ;
27
29
import com .google .cloud .spring .core .Retry ;
28
30
import com .google .cloud .spring .core .util .RetryUtil ;
29
- import com .google .iam .v2 .PoliciesClient ;
30
- import com .google .iam .v2 .PoliciesSettings ;
31
31
import java .io .IOException ;
32
32
import java .util .Collections ;
33
33
import javax .annotation .Generated ;
44
44
45
45
// AUTO-GENERATED DOCUMENTATION AND CLASS.
46
46
/**
47
- * Auto-configuration for {@link PoliciesClient }.
47
+ * Auto-configuration for {@link ReservationBlocksClient }.
48
48
*
49
49
* <p>Provides auto-configuration for Spring Boot
50
50
*
60
60
@ BetaApi ("Autogenerated Spring autoconfiguration is not yet stable" )
61
61
@ AutoConfiguration
62
62
@ AutoConfigureAfter (GcpContextAutoConfiguration .class )
63
- @ ConditionalOnClass (PoliciesClient .class )
64
- @ ConditionalOnProperty (value = "com.google.iam.v2.policies.enabled" , matchIfMissing = true )
65
- @ EnableConfigurationProperties (PoliciesSpringProperties .class )
66
- public class PoliciesSpringAutoConfiguration {
67
- private final PoliciesSpringProperties clientProperties ;
63
+ @ ConditionalOnClass (ReservationBlocksClient .class )
64
+ @ ConditionalOnProperty (
65
+ value = "com.google.cloud.compute.v1.reservation-blocks.enabled" ,
66
+ matchIfMissing = true )
67
+ @ EnableConfigurationProperties (ReservationBlocksSpringProperties .class )
68
+ public class ReservationBlocksSpringAutoConfiguration {
69
+ private final ReservationBlocksSpringProperties clientProperties ;
68
70
private final CredentialsProvider credentialsProvider ;
69
- private static final Log LOGGER = LogFactory .getLog (PoliciesSpringAutoConfiguration .class );
71
+ private static final Log LOGGER =
72
+ LogFactory .getLog (ReservationBlocksSpringAutoConfiguration .class );
70
73
71
- protected PoliciesSpringAutoConfiguration (
72
- PoliciesSpringProperties clientProperties , CredentialsProvider credentialsProvider )
74
+ protected ReservationBlocksSpringAutoConfiguration (
75
+ ReservationBlocksSpringProperties clientProperties , CredentialsProvider credentialsProvider )
73
76
throws IOException {
74
77
this .clientProperties = clientProperties ;
75
78
if (this .clientProperties .getCredentials ().hasKey ()) {
76
79
if (LOGGER .isTraceEnabled ()) {
77
- LOGGER .trace ("Using credentials from Policies -specific configuration" );
80
+ LOGGER .trace ("Using credentials from ReservationBlocks -specific configuration" );
78
81
}
79
82
this .credentialsProvider =
80
83
((CredentialsProvider ) new DefaultCredentialsProvider (this .clientProperties ));
@@ -92,45 +95,38 @@ protected PoliciesSpringAutoConfiguration(
92
95
* @return a default transport channel provider.
93
96
*/
94
97
@ Bean
95
- @ ConditionalOnMissingBean (name = "defaultPoliciesTransportChannelProvider" )
96
- public TransportChannelProvider defaultPoliciesTransportChannelProvider () {
97
- if (this .clientProperties .getUseRest ()) {
98
- return PoliciesSettings .defaultHttpJsonTransportProviderBuilder ().build ();
99
- }
100
- return PoliciesSettings .defaultTransportChannelProvider ();
98
+ @ ConditionalOnMissingBean (name = "defaultReservationBlocksTransportChannelProvider" )
99
+ public TransportChannelProvider defaultReservationBlocksTransportChannelProvider () {
100
+ return ReservationBlocksSettings .defaultTransportChannelProvider ();
101
101
}
102
102
103
103
/**
104
- * Provides a PoliciesSettings bean configured to use a DefaultCredentialsProvider and the client
105
- * library's default transport channel provider (defaultPoliciesTransportChannelProvider()). It
106
- * also configures the quota project ID and executor thread count, if provided through properties.
104
+ * Provides a ReservationBlocksSettings bean configured to use a DefaultCredentialsProvider and
105
+ * the client library's default transport channel provider
106
+ * (defaultReservationBlocksTransportChannelProvider()). It also configures the quota project ID
107
+ * and executor thread count, if provided through properties.
107
108
*
108
109
* <p>Retry settings are also configured from service-level and method-level properties specified
109
- * in PoliciesSpringProperties. Method-level properties will take precedence over service-level
110
- * properties if available, and client library defaults will be used if neither are specified.
110
+ * in ReservationBlocksSpringProperties. Method-level properties will take precedence over
111
+ * service-level properties if available, and client library defaults will be used if neither are
112
+ * specified.
111
113
*
112
114
* @param defaultTransportChannelProvider TransportChannelProvider to use in the settings.
113
- * @return a {@link PoliciesSettings} bean configured with {@link TransportChannelProvider} bean.
115
+ * @return a {@link ReservationBlocksSettings} bean configured with {@link
116
+ * TransportChannelProvider} bean.
114
117
*/
115
118
@ Bean
116
119
@ ConditionalOnMissingBean
117
- public PoliciesSettings policiesSettings (
118
- @ Qualifier ("defaultPoliciesTransportChannelProvider " )
120
+ public ReservationBlocksSettings reservationBlocksSettings (
121
+ @ Qualifier ("defaultReservationBlocksTransportChannelProvider " )
119
122
TransportChannelProvider defaultTransportChannelProvider )
120
123
throws IOException {
121
- PoliciesSettings .Builder clientSettingsBuilder ;
122
- if (this .clientProperties .getUseRest ()) {
123
- clientSettingsBuilder = PoliciesSettings .newHttpJsonBuilder ();
124
- if (LOGGER .isTraceEnabled ()) {
125
- LOGGER .trace ("Using REST (HTTP/JSON) transport." );
126
- }
127
- } else {
128
- clientSettingsBuilder = PoliciesSettings .newBuilder ();
129
- }
124
+ ReservationBlocksSettings .Builder clientSettingsBuilder =
125
+ ReservationBlocksSettings .newBuilder ();
130
126
clientSettingsBuilder
131
127
.setCredentialsProvider (this .credentialsProvider )
132
128
.setTransportChannelProvider (defaultTransportChannelProvider )
133
- .setEndpoint (PoliciesSettings .getDefaultEndpoint ())
129
+ .setEndpoint (ReservationBlocksSettings .getDefaultEndpoint ())
134
130
.setHeaderProvider (this .userAgentHeaderProvider ());
135
131
if (this .clientProperties .getQuotaProjectId () != null ) {
136
132
clientSettingsBuilder .setQuotaProjectId (this .clientProperties .getQuotaProjectId ());
@@ -143,7 +139,7 @@ public PoliciesSettings policiesSettings(
143
139
}
144
140
if (this .clientProperties .getExecutorThreadCount () != null ) {
145
141
ExecutorProvider executorProvider =
146
- PoliciesSettings .defaultExecutorProviderBuilder ()
142
+ ReservationBlocksSettings .defaultExecutorProviderBuilder ()
147
143
.setExecutorThreadCount (this .clientProperties .getExecutorThreadCount ())
148
144
.build ();
149
145
clientSettingsBuilder .setBackgroundExecutorProvider (executorProvider );
@@ -155,57 +151,59 @@ public PoliciesSettings policiesSettings(
155
151
}
156
152
Retry serviceRetry = clientProperties .getRetry ();
157
153
if (serviceRetry != null ) {
158
- RetrySettings listPoliciesRetrySettings =
154
+ RetrySettings getRetrySettings =
159
155
RetryUtil .updateRetrySettings (
160
- clientSettingsBuilder .listPoliciesSettings ().getRetrySettings (), serviceRetry );
161
- clientSettingsBuilder .listPoliciesSettings ().setRetrySettings (listPoliciesRetrySettings );
156
+ clientSettingsBuilder .getSettings ().getRetrySettings (), serviceRetry );
157
+ clientSettingsBuilder .getSettings ().setRetrySettings (getRetrySettings );
162
158
163
- RetrySettings getPolicyRetrySettings =
159
+ RetrySettings listRetrySettings =
164
160
RetryUtil .updateRetrySettings (
165
- clientSettingsBuilder .getPolicySettings ().getRetrySettings (), serviceRetry );
166
- clientSettingsBuilder .getPolicySettings ().setRetrySettings (getPolicyRetrySettings );
161
+ clientSettingsBuilder .listSettings ().getRetrySettings (), serviceRetry );
162
+ clientSettingsBuilder .listSettings ().setRetrySettings (listRetrySettings );
167
163
168
164
if (LOGGER .isTraceEnabled ()) {
169
165
LOGGER .trace ("Configured service-level retry settings from properties." );
170
166
}
171
167
}
172
- Retry listPoliciesRetry = clientProperties .getListPoliciesRetry ();
173
- if (listPoliciesRetry != null ) {
174
- RetrySettings listPoliciesRetrySettings =
168
+ Retry getRetry = clientProperties .getGetRetry ();
169
+ if (getRetry != null ) {
170
+ RetrySettings getRetrySettings =
175
171
RetryUtil .updateRetrySettings (
176
- clientSettingsBuilder .listPoliciesSettings ().getRetrySettings (), listPoliciesRetry );
177
- clientSettingsBuilder .listPoliciesSettings ().setRetrySettings (listPoliciesRetrySettings );
172
+ clientSettingsBuilder .getSettings ().getRetrySettings (), getRetry );
173
+ clientSettingsBuilder .getSettings ().setRetrySettings (getRetrySettings );
178
174
if (LOGGER .isTraceEnabled ()) {
179
- LOGGER .trace ("Configured method-level retry settings for listPolicies from properties." );
175
+ LOGGER .trace ("Configured method-level retry settings for get from properties." );
180
176
}
181
177
}
182
- Retry getPolicyRetry = clientProperties .getGetPolicyRetry ();
183
- if (getPolicyRetry != null ) {
184
- RetrySettings getPolicyRetrySettings =
178
+ Retry listRetry = clientProperties .getListRetry ();
179
+ if (listRetry != null ) {
180
+ RetrySettings listRetrySettings =
185
181
RetryUtil .updateRetrySettings (
186
- clientSettingsBuilder .getPolicySettings ().getRetrySettings (), getPolicyRetry );
187
- clientSettingsBuilder .getPolicySettings ().setRetrySettings (getPolicyRetrySettings );
182
+ clientSettingsBuilder .listSettings ().getRetrySettings (), listRetry );
183
+ clientSettingsBuilder .listSettings ().setRetrySettings (listRetrySettings );
188
184
if (LOGGER .isTraceEnabled ()) {
189
- LOGGER .trace ("Configured method-level retry settings for getPolicy from properties." );
185
+ LOGGER .trace ("Configured method-level retry settings for list from properties." );
190
186
}
191
187
}
192
188
return clientSettingsBuilder .build ();
193
189
}
194
190
195
191
/**
196
- * Provides a PoliciesClient bean configured with PoliciesSettings .
192
+ * Provides a ReservationBlocksClient bean configured with ReservationBlocksSettings .
197
193
*
198
- * @param policiesSettings settings to configure an instance of client bean.
199
- * @return a {@link PoliciesClient} bean configured with {@link PoliciesSettings}
194
+ * @param reservationBlocksSettings settings to configure an instance of client bean.
195
+ * @return a {@link ReservationBlocksClient} bean configured with {@link
196
+ * ReservationBlocksSettings}
200
197
*/
201
198
@ Bean
202
199
@ ConditionalOnMissingBean
203
- public PoliciesClient policiesClient (PoliciesSettings policiesSettings ) throws IOException {
204
- return PoliciesClient .create (policiesSettings );
200
+ public ReservationBlocksClient reservationBlocksClient (
201
+ ReservationBlocksSettings reservationBlocksSettings ) throws IOException {
202
+ return ReservationBlocksClient .create (reservationBlocksSettings );
205
203
}
206
204
207
205
private HeaderProvider userAgentHeaderProvider () {
208
- String springLibrary = "spring-autogen-policies " ;
206
+ String springLibrary = "spring-autogen-reservation-blocks " ;
209
207
String version = this .getClass ().getPackage ().getImplementationVersion ();
210
208
return () -> Collections .singletonMap ("user-agent" , springLibrary + "/" + version );
211
209
}
0 commit comments