Skip to content

Commit

Permalink
CodeGen from PR 29483 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge b0eecac9660020b988983448b6a8ff9fbc2e47ff into 2b6c728b10f0d8eca8bad4e7f009e38334ea7f1c
  • Loading branch information
SDKAuto committed Jun 26, 2024
1 parent 1c001df commit 742925d
Show file tree
Hide file tree
Showing 130 changed files with 17,738 additions and 2,905 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.azure.core.client.traits.TokenCredentialTrait;
import com.azure.core.credential.TokenCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
Expand All @@ -21,8 +20,8 @@
import com.azure.core.http.policy.AddHeadersFromContextPolicy;
import com.azure.core.http.policy.AddHeadersPolicy;
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpLoggingPolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.HttpPolicyProviders;
import com.azure.core.http.policy.RequestIdPolicy;
Expand Down Expand Up @@ -84,7 +83,7 @@ public EasmClientBuilder() {
@Override
public EasmClientBuilder pipeline(HttpPipeline pipeline) {
if (this.pipeline != null && pipeline == null) {
LOGGER.info("HttpPipeline is being set to 'null' when it was previously configured.");
LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured.");
}
this.pipeline = pipeline;
return this;
Expand Down Expand Up @@ -213,60 +212,6 @@ public EasmClientBuilder endpoint(String endpoint) {
return this;
}

/*
* The ID of the target subscription.
*/
@Generated
private String subscriptionId;

/**
* Sets The ID of the target subscription.
*
* @param subscriptionId the subscriptionId value.
* @return the EasmClientBuilder.
*/
@Generated
public EasmClientBuilder subscriptionId(String subscriptionId) {
this.subscriptionId = subscriptionId;
return this;
}

/*
* The name of the Resource Group.
*/
@Generated
private String resourceGroupName;

/**
* Sets The name of the Resource Group.
*
* @param resourceGroupName the resourceGroupName value.
* @return the EasmClientBuilder.
*/
@Generated
public EasmClientBuilder resourceGroupName(String resourceGroupName) {
this.resourceGroupName = resourceGroupName;
return this;
}

/*
* The name of the Workspace.
*/
@Generated
private String workspaceName;

/**
* Sets The name of the Workspace.
*
* @param workspaceName the workspaceName value.
* @return the EasmClientBuilder.
*/
@Generated
public EasmClientBuilder workspaceName(String workspaceName) {
this.workspaceName = workspaceName;
return this;
}

/*
* Service version
*/
Expand Down Expand Up @@ -310,11 +255,12 @@ public EasmClientBuilder retryPolicy(RetryPolicy retryPolicy) {
*/
@Generated
private EasmClientImpl buildInnerClient() {
this.validateClient();
HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline();
EasmServiceVersion localServiceVersion
= (serviceVersion != null) ? serviceVersion : EasmServiceVersion.getLatest();
EasmClientImpl client = new EasmClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(),
this.endpoint, this.subscriptionId, this.resourceGroupName, this.workspaceName, localServiceVersion);
this.endpoint, localServiceVersion);
return client;
}

Expand All @@ -331,26 +277,28 @@ private HttpPipeline createHttpPipeline() {
policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration));
policies.add(new RequestIdPolicy());
policies.add(new AddHeadersFromContextPolicy());
HttpHeaders headers = new HttpHeaders();
localClientOptions.getHeaders()
.forEach(header -> headers.set(HttpHeaderName.fromString(header.getName()), header.getValue()));
if (headers.getSize() > 0) {
HttpHeaders headers = CoreUtils.createHttpHeadersFromClientOptions(localClientOptions);
if (headers != null) {
policies.add(new AddHeadersPolicy(headers));
}
this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy()));
policies.add(new AddDatePolicy());
if (tokenCredential != null) {
policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES));
}
this.pipelinePolicies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(localHttpLogOptions));
HttpPipeline httpPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient).clientOptions(localClientOptions).build();
.httpClient(httpClient)
.clientOptions(localClientOptions)
.build();
return httpPipeline;
}

Expand All @@ -375,4 +323,11 @@ public EasmClient buildClient() {
}

private static final ClientLogger LOGGER = new ClientLogger(EasmClientBuilder.class);

@Generated
private void validateClient() {
// This method is invoked from 'buildInnerClient'/'buildClient' method.
// Developer can customize this method, to validate that the necessary conditions are met for the new client.
Objects.requireNonNull(endpoint, "'endpoint' cannot be null.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public enum EasmServiceVersion implements ServiceVersion {
/**
* Enum value 2023-03-01-preview.
*/
V2023_03_01_PREVIEW("2023-03-01-preview");
V2023_03_01_PREVIEW("2023-03-01-preview"),

/**
* Enum value 2024-03-01-preview.
*/
V2024_03_01_PREVIEW("2024-03-01-preview");

private final String version;

Expand All @@ -35,6 +40,6 @@ public String getVersion() {
* @return The latest {@link EasmServiceVersion}.
*/
public static EasmServiceVersion getLatest() {
return V2023_03_01_PREVIEW;
return V2024_03_01_PREVIEW;
}
}
Loading

0 comments on commit 742925d

Please sign in to comment.