@@ -171,135 +171,26 @@ public AuditClient(
171
171
* @return builder
172
172
*/
173
173
public static Builder builder () {
174
- return new Builder ();
174
+ return new Builder (SERVICE );
175
175
}
176
176
177
177
/**
178
178
* Builder class for this client. The "authenticationDetailsProvider" is required and must be passed to the
179
- * {@link #build(AbstractAuthenticationDetailsProvider)} method.
179
+ * {@link #build(AbstractAuthenticationDetailsProvider)} or {@link #buildAsync(AbstractAuthenticationDetailsProvider)} method.
180
180
*/
181
- public static class Builder {
182
- protected com .oracle .bmc .ClientConfiguration configuration ;
183
- protected com .oracle .bmc .http .ClientConfigurator clientConfigurator ;
184
- protected java .util .List <com .oracle .bmc .http .ClientConfigurator >
185
- additionalClientConfigurators = new java .util .ArrayList <>();
186
- protected com .oracle .bmc .http .signing .RequestSignerFactory requestSignerFactory =
187
- new com .oracle .bmc .http .signing .internal .DefaultRequestSignerFactory (
188
- com .oracle .bmc .http .signing .SigningStrategy .STANDARD );
189
- protected String endpoint ;
190
-
191
- private Builder () {}
192
-
193
- private Builder (
194
- com .oracle .bmc .ClientConfiguration configuration ,
195
- com .oracle .bmc .http .ClientConfigurator clientConfigurator ,
196
- java .util .List <com .oracle .bmc .http .ClientConfigurator >
197
- additionalClientConfigurators ,
198
- com .oracle .bmc .http .signing .RequestSignerFactory requestSignerFactory ) {
199
- this .configuration = configuration ;
200
- this .clientConfigurator = clientConfigurator ;
201
- this .additionalClientConfigurators = additionalClientConfigurators ;
202
- }
203
-
204
- /**
205
- * Set the configuration. May be null.
206
- * @param configuration configuration. May be null.
207
- * @return this builder
208
- */
209
- public Builder configuration (com .oracle .bmc .ClientConfiguration configuration ) {
210
- this .configuration = configuration ;
211
- return this ;
212
- }
213
-
214
- /**
215
- * Set the client configurator. May be null.
216
- * @param clientConfigurator client configurator. May be null.
217
- * @return this builder
218
- */
219
- public Builder clientConfigurator (
220
- com .oracle .bmc .http .ClientConfigurator clientConfigurator ) {
221
- this .clientConfigurator = clientConfigurator ;
222
- return this ;
223
- }
224
-
225
- /**
226
- * Add an additional client configurator to be run after the primary configurator.
227
- * @param additionalClientConfigurator the additional client configurator
228
- * @return this builder
229
- */
230
- public Builder additionalClientConfigurator (
231
- @ lombok .NonNull
232
- com .oracle .bmc .http .ClientConfigurator additionalClientConfigurator ) {
233
- this .additionalClientConfigurators .add (additionalClientConfigurator );
234
- return this ;
235
- }
236
-
237
- /**
238
- * Set the request signer factory. May be null.
239
- * @param requestSignerFactory request signer factory. May be null.
240
- * @return this builder
241
- */
242
- public Builder requestSignerFactory (
243
- com .oracle .bmc .http .signing .RequestSignerFactory requestSignerFactory ) {
244
- if (requestSignerFactory == null ) {
245
- this .requestSignerFactory =
246
- new com .oracle .bmc .http .signing .internal .DefaultRequestSignerFactory (
247
- com .oracle .bmc .http .signing .SigningStrategy .STANDARD );
248
- } else {
249
- this .requestSignerFactory = requestSignerFactory ;
250
- }
251
- return this ;
252
- }
253
-
254
- /**
255
- * Set the endpoint for the client to be created.
256
- * @param endpoint endpoint
257
- * @return this builder
258
- */
259
- public Builder endpoint (String endpoint ) {
260
- this .endpoint = endpoint ;
261
- return this ;
262
- }
263
-
264
- /**
265
- * Set the region for the client to be created.
266
- * @param region region
267
- * @return this builder
268
- */
269
- public Builder region (com .oracle .bmc .Region region ) {
270
- com .google .common .base .Optional <String > endpoint = region .getEndpoint (SERVICE );
271
- if (endpoint .isPresent ()) {
272
- endpoint (endpoint .get ());
273
- } else {
274
- throw new IllegalArgumentException (
275
- "Endpoint for " + SERVICE + " is not known in region " + region );
276
- }
277
- return this ;
278
- }
279
-
280
- /**
281
- * Set the region for the client to be created.
282
- * @param region region
283
- * @return this builder
284
- */
285
- public Builder region (String regionId ) {
286
- regionId = regionId .toLowerCase (Locale .ENGLISH );
287
- try {
288
- com .oracle .bmc .Region region = com .oracle .bmc .Region .fromRegionId (regionId );
289
- return region (region );
290
- } catch (IllegalArgumentException e ) {
291
- LOG .info (
292
- "Unknown regionId '{}', falling back to default endpoint format" , regionId );
293
- String endpoint =
294
- com .oracle .bmc .Region .formatDefaultRegionEndpoint (SERVICE , regionId );
295
- return endpoint (endpoint );
296
- }
181
+ public static class Builder
182
+ extends com .oracle .bmc .common .RegionalClientBuilder <Builder , AuditClient > {
183
+ private Builder (com .oracle .bmc .Service service ) {
184
+ super (service );
185
+ requestSignerFactory =
186
+ new com .oracle .bmc .http .signing .internal .DefaultRequestSignerFactory (
187
+ com .oracle .bmc .http .signing .SigningStrategy .STANDARD );
297
188
}
298
189
299
190
/**
300
- * Set the authentication details provider. Once this is called, the builder can build the client.
191
+ * Build the client.
301
192
* @param authenticationDetailsProvider authentication details provider
302
- * @return a builder that can build the client
193
+ * @return the client
303
194
*/
304
195
public AuditClient build (
305
196
@ lombok .NonNull
0 commit comments