1212import com .azure .core .client .traits .TokenCredentialTrait ;
1313import com .azure .core .credential .TokenCredential ;
1414import com .azure .core .http .HttpClient ;
15- import com .azure .core .http .HttpHeaderName ;
1615import com .azure .core .http .HttpHeaders ;
1716import com .azure .core .http .HttpPipeline ;
1817import com .azure .core .http .HttpPipelineBuilder ;
2120import com .azure .core .http .policy .AddHeadersFromContextPolicy ;
2221import com .azure .core .http .policy .AddHeadersPolicy ;
2322import com .azure .core .http .policy .BearerTokenAuthenticationPolicy ;
24- import com .azure .core .http .policy .HttpLogOptions ;
2523import com .azure .core .http .policy .HttpLoggingPolicy ;
24+ import com .azure .core .http .policy .HttpLogOptions ;
2625import com .azure .core .http .policy .HttpPipelinePolicy ;
2726import com .azure .core .http .policy .HttpPolicyProviders ;
2827import com .azure .core .http .policy .RequestIdPolicy ;
@@ -84,7 +83,7 @@ public EasmClientBuilder() {
8483 @ Override
8584 public EasmClientBuilder pipeline (HttpPipeline pipeline ) {
8685 if (this .pipeline != null && pipeline == null ) {
87- LOGGER .info ("HttpPipeline is being set to 'null' when it was previously configured." );
86+ LOGGER .atInfo (). log ("HttpPipeline is being set to 'null' when it was previously configured." );
8887 }
8988 this .pipeline = pipeline ;
9089 return this ;
@@ -213,60 +212,6 @@ public EasmClientBuilder endpoint(String endpoint) {
213212 return this ;
214213 }
215214
216- /*
217- * The ID of the target subscription.
218- */
219- @ Generated
220- private String subscriptionId ;
221-
222- /**
223- * Sets The ID of the target subscription.
224- *
225- * @param subscriptionId the subscriptionId value.
226- * @return the EasmClientBuilder.
227- */
228- @ Generated
229- public EasmClientBuilder subscriptionId (String subscriptionId ) {
230- this .subscriptionId = subscriptionId ;
231- return this ;
232- }
233-
234- /*
235- * The name of the Resource Group.
236- */
237- @ Generated
238- private String resourceGroupName ;
239-
240- /**
241- * Sets The name of the Resource Group.
242- *
243- * @param resourceGroupName the resourceGroupName value.
244- * @return the EasmClientBuilder.
245- */
246- @ Generated
247- public EasmClientBuilder resourceGroupName (String resourceGroupName ) {
248- this .resourceGroupName = resourceGroupName ;
249- return this ;
250- }
251-
252- /*
253- * The name of the Workspace.
254- */
255- @ Generated
256- private String workspaceName ;
257-
258- /**
259- * Sets The name of the Workspace.
260- *
261- * @param workspaceName the workspaceName value.
262- * @return the EasmClientBuilder.
263- */
264- @ Generated
265- public EasmClientBuilder workspaceName (String workspaceName ) {
266- this .workspaceName = workspaceName ;
267- return this ;
268- }
269-
270215 /*
271216 * Service version
272217 */
@@ -310,11 +255,12 @@ public EasmClientBuilder retryPolicy(RetryPolicy retryPolicy) {
310255 */
311256 @ Generated
312257 private EasmClientImpl buildInnerClient () {
258+ this .validateClient ();
313259 HttpPipeline localPipeline = (pipeline != null ) ? pipeline : createHttpPipeline ();
314260 EasmServiceVersion localServiceVersion
315261 = (serviceVersion != null ) ? serviceVersion : EasmServiceVersion .getLatest ();
316262 EasmClientImpl client = new EasmClientImpl (localPipeline , JacksonAdapter .createDefaultSerializerAdapter (),
317- this .endpoint , this . subscriptionId , this . resourceGroupName , this . workspaceName , localServiceVersion );
263+ this .endpoint , localServiceVersion );
318264 return client ;
319265 }
320266
@@ -331,26 +277,28 @@ private HttpPipeline createHttpPipeline() {
331277 policies .add (new UserAgentPolicy (applicationId , clientName , clientVersion , buildConfiguration ));
332278 policies .add (new RequestIdPolicy ());
333279 policies .add (new AddHeadersFromContextPolicy ());
334- HttpHeaders headers = new HttpHeaders ();
335- localClientOptions .getHeaders ()
336- .forEach (header -> headers .set (HttpHeaderName .fromString (header .getName ()), header .getValue ()));
337- if (headers .getSize () > 0 ) {
280+ HttpHeaders headers = CoreUtils .createHttpHeadersFromClientOptions (localClientOptions );
281+ if (headers != null ) {
338282 policies .add (new AddHeadersPolicy (headers ));
339283 }
340- this .pipelinePolicies .stream ().filter (p -> p .getPipelinePosition () == HttpPipelinePosition .PER_CALL )
284+ this .pipelinePolicies .stream ()
285+ .filter (p -> p .getPipelinePosition () == HttpPipelinePosition .PER_CALL )
341286 .forEach (p -> policies .add (p ));
342287 HttpPolicyProviders .addBeforeRetryPolicies (policies );
343288 policies .add (ClientBuilderUtil .validateAndGetRetryPolicy (retryPolicy , retryOptions , new RetryPolicy ()));
344289 policies .add (new AddDatePolicy ());
345290 if (tokenCredential != null ) {
346291 policies .add (new BearerTokenAuthenticationPolicy (tokenCredential , DEFAULT_SCOPES ));
347292 }
348- this .pipelinePolicies .stream ().filter (p -> p .getPipelinePosition () == HttpPipelinePosition .PER_RETRY )
293+ this .pipelinePolicies .stream ()
294+ .filter (p -> p .getPipelinePosition () == HttpPipelinePosition .PER_RETRY )
349295 .forEach (p -> policies .add (p ));
350296 HttpPolicyProviders .addAfterRetryPolicies (policies );
351297 policies .add (new HttpLoggingPolicy (localHttpLogOptions ));
352298 HttpPipeline httpPipeline = new HttpPipelineBuilder ().policies (policies .toArray (new HttpPipelinePolicy [0 ]))
353- .httpClient (httpClient ).clientOptions (localClientOptions ).build ();
299+ .httpClient (httpClient )
300+ .clientOptions (localClientOptions )
301+ .build ();
354302 return httpPipeline ;
355303 }
356304
@@ -375,4 +323,11 @@ public EasmClient buildClient() {
375323 }
376324
377325 private static final ClientLogger LOGGER = new ClientLogger (EasmClientBuilder .class );
326+
327+ @ Generated
328+ private void validateClient () {
329+ // This method is invoked from 'buildInnerClient'/'buildClient' method.
330+ // Developer can customize this method, to validate that the necessary conditions are met for the new client.
331+ Objects .requireNonNull (endpoint , "'endpoint' cannot be null." );
332+ }
378333}
0 commit comments