Skip to content

Commit

Permalink
Remove audience support for GA (#24583)
Browse files Browse the repository at this point in the history
* Remove audience support for GA

* fix audience
  • Loading branch information
srnagar authored Oct 6, 2021
1 parent c1c4463 commit bc4a9fe
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.azure.core.util.Configuration;
import com.azure.core.util.logging.ClientLogger;
import com.azure.monitor.query.implementation.logs.AzureLogAnalyticsImplBuilder;
import com.azure.monitor.query.models.LogsQueryClientAudience;

/**
* Fluent builder for creating instances of {@link LogsQueryClient} and {@link LogsQueryAsyncClient}.
Expand Down Expand Up @@ -124,18 +123,6 @@ public LogsQueryClientBuilder clientOptions(ClientOptions clientOptions) {
return this;
}

/**
* Sets the audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience will be
* used if the property is null.
* @param audience audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience
* will be used if the property is null.
* @return the {@link LogsQueryClientBuilder}.
*/
public LogsQueryClientBuilder audience(LogsQueryClientAudience audience) {
innerLogBuilder.audience(audience == null ? null : audience.toString());
return this;
}

/**
* The service version to use when creating the client.
* @param serviceVersion The {@link LogsQueryServiceVersion}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.azure.monitor.query.implementation.metrics.MonitorManagementClientImplBuilder;
import com.azure.monitor.query.implementation.metricsdefinitions.MetricsDefinitionsClientImplBuilder;
import com.azure.monitor.query.implementation.metricsnamespaces.MetricsNamespacesClientImplBuilder;
import com.azure.monitor.query.models.MetricsQueryClientAudience;

/**
* Fluent builder for creating instances of {@link MetricsQueryClient} and {@link MetricsQueryAsyncClient}.
Expand Down Expand Up @@ -138,20 +137,6 @@ public MetricsQueryClientBuilder credential(TokenCredential tokenCredential) {
return this;
}

/**
* Sets the audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience will be
* used if the property is null.
* @param audience audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience
* will be used if the property is null.
* @return the {@link MetricsQueryClientBuilder}.
*/
public MetricsQueryClientBuilder audience(MetricsQueryClientAudience audience) {
innerMetricsBuilder.audience(audience == null ? null : audience.toString());
innerMetricsDefinitionsBuilder.audience(audience == null ? null : audience.toString());
innerMetricsNamespaceBuilder.audience(audience == null ? null : audience.toString());
return this;
}

/**
* Set the {@link ClientOptions} used for creating the client.
* @param clientOptions The {@link ClientOptions}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
import com.azure.core.util.CoreUtils;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.monitor.query.LogsQueryClientBuilder;
import com.azure.monitor.query.models.LogsQueryClientAudience;
import com.azure.monitor.query.models.MetricsQueryClientAudience;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -37,7 +34,6 @@ public final class AzureLogAnalyticsImplBuilder {
private static final String SDK_VERSION = "version";

private final Map<String, String> properties = CoreUtils.getProperties("azure-monitor-query.properties");
private String audience;

/** Create an instance of the AzureLogAnalyticsImplBuilder. */
public AzureLogAnalyticsImplBuilder() {
Expand Down Expand Up @@ -190,18 +186,6 @@ public AzureLogAnalyticsImplBuilder addPolicy(HttpPipelinePolicy customPolicy) {
return this;
}

/**
* Sets the audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience will be
* used if the property is null.
* @param audience audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience
* will be used if the property is null.
* @return the {@link AzureLogAnalyticsImplBuilder}.
*/
public AzureLogAnalyticsImplBuilder audience(String audience) {
this.audience = audience;
return this;
}

/**
* Builds an instance of AzureLogAnalyticsImpl with the provided parameters.
*
Expand Down Expand Up @@ -235,11 +219,7 @@ private HttpPipeline createHttpPipeline() {
new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, buildConfiguration));
HttpPolicyProviders.addBeforeRetryPolicies(policies);

String resolvedAudience = this.audience;
if (resolvedAudience == null) {
resolvedAudience = LogsQueryClientAudience.AZURE_PUBLIC_CLOUD.toString();
}
resolvedAudience += "/.default";
String resolvedAudience = host + "/.default";
BearerTokenAuthenticationPolicy tokenPolicy = new BearerTokenAuthenticationPolicy(this.tokenCredential,
resolvedAudience);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.azure.core.util.CoreUtils;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.monitor.query.models.MetricsQueryClientAudience;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,7 +34,6 @@ public final class MonitorManagementClientImplBuilder {
private static final String SDK_VERSION = "version";

private final Map<String, String> properties = CoreUtils.getProperties("azure-monitor-query.properties");
private String audience;

/** Create an instance of the MonitorManagementClientImplBuilder. */
public MonitorManagementClientImplBuilder() {
Expand Down Expand Up @@ -204,18 +202,6 @@ public MonitorManagementClientImplBuilder addPolicy(HttpPipelinePolicy customPol
return this;
}

/**
* Sets the audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience will be
* used if the property is null.
* @param audience audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience
* will be used if the property is null.
* @return the {@link MonitorManagementClientImplBuilder}.
*/
public MonitorManagementClientImplBuilder audience(String audience) {
this.audience = audience;
return this;
}

/**
* Builds an instance of MonitorManagementClientImpl with the provided parameters.
*
Expand Down Expand Up @@ -253,11 +239,7 @@ private HttpPipeline createHttpPipeline() {
new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, buildConfiguration));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy);
String resolvedAudience = this.audience;
if (resolvedAudience == null) {
resolvedAudience = MetricsQueryClientAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD.toString();
}
resolvedAudience += "/.default";
String resolvedAudience = host + "/.default";
BearerTokenAuthenticationPolicy tokenPolicy = new BearerTokenAuthenticationPolicy(this.tokenCredential,
resolvedAudience);
policies.add(tokenPolicy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.azure.core.util.CoreUtils;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.monitor.query.models.MetricsQueryClientAudience;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,7 +34,6 @@ public final class MetricsDefinitionsClientImplBuilder {
private static final String SDK_VERSION = "version";

private final Map<String, String> properties = CoreUtils.getProperties("azure-monitor-query.properties");
private String audience;

/** Create an instance of the MetricsDefinitionsClientImplBuilder. */
public MetricsDefinitionsClientImplBuilder() {
Expand Down Expand Up @@ -204,18 +202,6 @@ public MetricsDefinitionsClientImplBuilder addPolicy(HttpPipelinePolicy customPo
return this;
}

/**
* Sets the audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience will be
* used if the property is null.
* @param audience audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience
* will be used if the property is null.
* @return the {@link MetricsDefinitionsClientImplBuilder}.
*/
public MetricsDefinitionsClientImplBuilder audience(String audience) {
this.audience = audience;
return this;
}

/**
* Builds an instance of MetricsDefinitionsClientImpl with the provided parameters.
*
Expand Down Expand Up @@ -251,11 +237,7 @@ private HttpPipeline createHttpPipeline() {
policies.add(
new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, buildConfiguration));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
String resolvedAudience = this.audience;
if (resolvedAudience == null) {
resolvedAudience = MetricsQueryClientAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD.toString();
}
resolvedAudience += "/.default";
String resolvedAudience = host +"/.default";
BearerTokenAuthenticationPolicy tokenPolicy = new BearerTokenAuthenticationPolicy(this.tokenCredential,
resolvedAudience);
policies.add(tokenPolicy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.azure.core.util.CoreUtils;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.monitor.query.models.MetricsQueryClientAudience;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,7 +34,6 @@ public final class MetricsNamespacesClientImplBuilder {
private static final String SDK_VERSION = "version";

private final Map<String, String> properties = CoreUtils.getProperties("azure-monitor-query.properties");
private String audience;

/** Create an instance of the MetricsNamespacesClientImplBuilder. */
public MetricsNamespacesClientImplBuilder() {
Expand Down Expand Up @@ -204,18 +202,6 @@ public MetricsNamespacesClientImplBuilder addPolicy(HttpPipelinePolicy customPol
return this;
}

/**
* Sets the audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience will be
* used if the property is null.
* @param audience audience to use for authentication with Azure Active Directory. The Azure Public Cloud audience
* will be used if the property is null.
* @return the {@link MetricsNamespacesClientImplBuilder}.
*/
public MetricsNamespacesClientImplBuilder audience(String audience) {
this.audience = audience;
return this;
}

/**
* Builds an instance of MetricsNamespacesClientImpl with the provided parameters.
*
Expand Down Expand Up @@ -251,11 +237,7 @@ private HttpPipeline createHttpPipeline() {
policies.add(
new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, buildConfiguration));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
String resolvedAudience = this.audience;
if (resolvedAudience == null) {
resolvedAudience = MetricsQueryClientAudience.AZURE_RESOURCE_MANAGER_PUBLIC_CLOUD.toString();
}
resolvedAudience += "/.default";
String resolvedAudience = host + "/.default";
BearerTokenAuthenticationPolicy tokenPolicy = new BearerTokenAuthenticationPolicy(this.tokenCredential,
resolvedAudience);
policies.add(tokenPolicy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
/**
* Cloud audiences available for {@link LogsQueryClient}.
*/
public final class LogsQueryClientAudience extends ExpandableStringEnum<LogsQueryClientAudience> {
final class LogsQueryClientAudience extends ExpandableStringEnum<LogsQueryClientAudience> {

/** Static audience for Azure public cloud. */
public static final LogsQueryClientAudience AZURE_PUBLIC_CLOUD = fromString("https://api.monitor.azure.com");
public static final LogsQueryClientAudience AZURE_PUBLIC_CLOUD = fromString("https://api.loganalytics.io");

/** Static default audience that uses Azure public cloud. */
public static final LogsQueryClientAudience DEFAULT = fromString("https://api.monitor.azure.com");
public static final LogsQueryClientAudience DEFAULT = fromString("https://api.loganalytics.io");

/**
* Creates or finds a LogsQueryClientAudience from its string representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* Cloud audiences available for {@link MetricsQueryClient}.
*/
public final class MetricsQueryClientAudience extends ExpandableStringEnum<MetricsQueryClientAudience> {
final class MetricsQueryClientAudience extends ExpandableStringEnum<MetricsQueryClientAudience> {
/** Static value AZURE_RESOURCE_MANAGER_CHINA for MetricsQueryClientAudience. */
public static final MetricsQueryClientAudience AZURE_RESOURCE_MANAGER_CHINA = fromString("https://management.chinacloudapi.cn");

Expand Down

0 comments on commit bc4a9fe

Please sign in to comment.