From 93c25d89399d7790d6e5d92ffbdfc123675c6308 Mon Sep 17 00:00:00 2001
From: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com>
Date: Thu, 19 Sep 2024 17:45:00 -0400
Subject: [PATCH] Enable Spotless for azure-data-appconfiguration and
azure-data-appconfiguration-perf (#41950)
---
.../azure-data-appconfiguration-perf/pom.xml | 1 +
.../azure/data/appconfiguration/perf/App.java | 2 +-
.../perf/ListConfigurationSettingsTest.java | 8 +-
.../perf/core/ServiceTest.java | 6 +-
.../azure-data-appconfiguration/pom.xml | 1 +
.../ConfigurationAsyncClient.java | 132 +--
.../appconfiguration/ConfigurationClient.java | 109 ++-
.../ConfigurationClientBuilder.java | 44 +-
.../ConfigurationClientCredentials.java | 18 +-
.../ConfigurationCredentialsPolicy.java | 1 -
...igurationSettingDeserializationHelper.java | 33 +-
.../ConfigurationSettingHelper.java | 4 +-
...nfigurationSettingSerializationHelper.java | 4 +-
.../CreateSnapshotUtilClient.java | 73 +-
.../implementation/SyncToken.java | 13 +-
.../implementation/SyncTokenPolicy.java | 9 +-
.../implementation/Utility.java | 37 +-
.../models/ConfigurationSetting.java | 11 +-
.../FeatureFlagConfigurationSetting.java | 17 +-
.../SecretReferenceConfigurationSetting.java | 9 +-
.../models/SettingSelector.java | 4 +-
.../models/SnapshotSelector.java | 23 +-
.../ConfigurationAsyncClientTest.java | 857 +++++++++---------
.../ConfigurationClientBuilderTest.java | 72 +-
.../ConfigurationClientTest.java | 659 ++++++++------
.../ConfigurationClientTestBase.java | 156 ++--
.../FeatureFlagSettingUnitTest.java | 47 +-
...ReferenceConfigurationSettingUnitTest.java | 7 +-
.../appconfiguration/SettingSelectorTest.java | 10 +-
.../data/appconfiguration/TestHelper.java | 8 +-
.../ConfigurationCredentialPolicyTest.java | 8 +-
.../ConfigurationSettingDeserializerTest.java | 41 +-
.../ConfigurationSettingSerializerTest.java | 18 +-
.../implementation/SyncTokenPolicyTest.java | 26 +-
34 files changed, 1275 insertions(+), 1193 deletions(-)
diff --git a/sdk/appconfiguration/azure-data-appconfiguration-perf/pom.xml b/sdk/appconfiguration/azure-data-appconfiguration-perf/pom.xml
index e80d7fb995415..4aec69571d129 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration-perf/pom.xml
+++ b/sdk/appconfiguration/azure-data-appconfiguration-perf/pom.xml
@@ -21,6 +21,7 @@
com.azure.data.appconfiguration.perf.App
azure-data-appconfiguration-perf
+ false
diff --git a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/App.java b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/App.java
index b09d0b2b88def..8f30182c4799f 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/App.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/App.java
@@ -25,6 +25,6 @@ public class App {
* @param args Arguments to the performance tests.
*/
public static void main(String[] args) {
- PerfStressProgram.run(new Class>[]{ListConfigurationSettingsTest.class}, args);
+ PerfStressProgram.run(new Class>[] { ListConfigurationSettingsTest.class }, args);
}
}
diff --git a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/ListConfigurationSettingsTest.java b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/ListConfigurationSettingsTest.java
index 03ae9c519dbf0..033452ccf802d 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/ListConfigurationSettingsTest.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/ListConfigurationSettingsTest.java
@@ -37,8 +37,8 @@ public ListConfigurationSettingsTest(PerfStressOptions options) {
public Mono globalSetupAsync() {
List> settingMonoList = new ArrayList<>();
for (int i = 0; i < settingCount; i++) {
- settingMonoList.add(configurationAsyncClient.setConfigurationSetting(
- new ConfigurationSetting().setKey(KEY_PREFIX + i).setValue(SETTING_VALUE)));
+ settingMonoList.add(configurationAsyncClient
+ .setConfigurationSetting(new ConfigurationSetting().setKey(KEY_PREFIX + i).setValue(SETTING_VALUE)));
}
return Flux.concat(settingMonoList).then();
@@ -48,8 +48,8 @@ public Mono globalSetupAsync() {
public Mono globalCleanupAsync() {
List> settingMonoList = new ArrayList<>();
for (int i = 0; i < settingCount; i++) {
- settingMonoList.add(configurationAsyncClient.deleteConfigurationSetting(
- new ConfigurationSetting().setKey(KEY_PREFIX + i).setValue(SETTING_VALUE)));
+ settingMonoList.add(configurationAsyncClient
+ .deleteConfigurationSetting(new ConfigurationSetting().setKey(KEY_PREFIX + i).setValue(SETTING_VALUE)));
}
return Flux.concat(settingMonoList).then();
diff --git a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/core/ServiceTest.java b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/core/ServiceTest.java
index c7416a0b1115e..3969cbd57fb43 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/core/ServiceTest.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/core/ServiceTest.java
@@ -15,8 +15,8 @@
* Base class for Azure App Configuration performance tests.
*/
public abstract class ServiceTest extends PerfStressTest {
- private static final String CONFIGURATION_ERROR = "Configuration %s must be set in either environment variables "
- + "or system properties.%n";
+ private static final String CONFIGURATION_ERROR
+ = "Configuration %s must be set in either environment variables " + "or system properties.%n";
protected final ConfigurationClient configurationClient;
protected final ConfigurationAsyncClient configurationAsyncClient;
@@ -39,6 +39,6 @@ public ServiceTest(TOptions options) {
ConfigurationClientBuilder builder = new ConfigurationClientBuilder().connectionString(connectionString);
this.configurationClient = builder.buildClient();
- this.configurationAsyncClient = builder.buildAsyncClient();
+ this.configurationAsyncClient = builder.buildAsyncClient();
}
}
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/pom.xml b/sdk/appconfiguration/azure-data-appconfiguration/pom.xml
index cccfef3e1c6a0..48ed21c0a8e40 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/pom.xml
+++ b/sdk/appconfiguration/azure-data-appconfiguration/pom.xml
@@ -45,6 +45,7 @@
false
--initialize-at-build-time=com.azure.data.appconfiguration.TestHelper
+ false
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationAsyncClient.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationAsyncClient.java
index 9ddca332521ec..111ab29765b3a 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationAsyncClient.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationAsyncClient.java
@@ -291,7 +291,9 @@
* @see ConfigurationClientBuilder
* @see ConfigurationSetting
*/
-@ServiceClient(builder = ConfigurationClientBuilder.class, isAsync = true,
+@ServiceClient(
+ builder = ConfigurationClientBuilder.class,
+ isAsync = true,
serviceInterfaces = AzureAppConfigurationImpl.AzureAppConfigurationService.class)
public final class ConfigurationAsyncClient {
private static final ClientLogger LOGGER = new ClientLogger(ConfigurationAsyncClient.class);
@@ -427,11 +429,10 @@ public Mono> addConfigurationSettingWithResponse(
// This service method call is similar to setConfigurationSetting except we're passing If-Not-Match = "*".
// If the service finds any existing configuration settings, then its e-tag will match and the service will
// return an error.
- return withContext(
- context -> validateSettingAsync(setting).flatMap(
- settingInternal -> serviceClient.putKeyValueWithResponseAsync(settingInternal.getKey(),
- settingInternal.getLabel(), null, ETAG_ANY, toKeyValue(settingInternal), context)
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
+ return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal -> serviceClient
+ .putKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(), null, ETAG_ANY,
+ toKeyValue(settingInternal), context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
}
/**
@@ -570,12 +571,10 @@ public Mono setConfigurationSetting(ConfigurationSetting s
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono> setConfigurationSettingWithResponse(ConfigurationSetting setting,
boolean ifUnchanged) {
- return withContext(
- context -> validateSettingAsync(setting).flatMap(
- settingInternal -> serviceClient.putKeyValueWithResponseAsync(settingInternal.getKey(),
- settingInternal.getLabel(), getETag(ifUnchanged, settingInternal), null,
- toKeyValue(settingInternal), context)
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
+ return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal -> serviceClient
+ .putKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(),
+ getETag(ifUnchanged, settingInternal), null, toKeyValue(settingInternal), context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
}
/**
@@ -592,7 +591,7 @@ public Mono> setConfigurationSettingWithResponse(
* response.getKey(), response.getLabel(), response.getValue()));
*
*
-
+
* @param key The key of the setting to retrieve.
* @param label The label of the configuration setting to retrieve. If {@code null} no label will be used.
* @return The {@link ConfigurationSetting} stored in the service, or an empty Mono if the configuration value does
@@ -716,20 +715,21 @@ public Mono getConfigurationSetting(ConfigurationSetting s
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono> getConfigurationSettingWithResponse(ConfigurationSetting setting,
OffsetDateTime acceptDateTime, boolean ifChanged) {
- return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal ->
- serviceClient.getKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(),
- acceptDateTime == null ? null : acceptDateTime.toString(), null,
- getETag(ifChanged, settingInternal), null, context)
- .onErrorResume(HttpResponseException.class,
- (Function>>) throwable -> {
- HttpResponseException e = (HttpResponseException) throwable;
- HttpResponse httpResponse = e.getResponse();
- if (httpResponse.getStatusCode() == 304) {
- return Mono.just(new ResponseBase(httpResponse.getRequest(),
- httpResponse.getStatusCode(), httpResponse.getHeaders(), null, null));
- }
- return Mono.error(throwable);
- }).map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
+ return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal -> serviceClient
+ .getKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(),
+ acceptDateTime == null ? null : acceptDateTime.toString(), null, getETag(ifChanged, settingInternal),
+ null, context)
+ .onErrorResume(HttpResponseException.class,
+ (Function>>) throwable -> {
+ HttpResponseException e = (HttpResponseException) throwable;
+ HttpResponse httpResponse = e.getResponse();
+ if (httpResponse.getStatusCode() == 304) {
+ return Mono.just(new ResponseBase(httpResponse.getRequest(),
+ httpResponse.getStatusCode(), httpResponse.getHeaders(), null, null));
+ }
+ return Mono.error(throwable);
+ })
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
}
/**
@@ -848,10 +848,10 @@ public Mono deleteConfigurationSetting(ConfigurationSettin
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono> deleteConfigurationSettingWithResponse(ConfigurationSetting setting,
boolean ifUnchanged) {
- return withContext(context -> validateSettingAsync(setting).flatMap(
- settingInternal -> serviceClient.deleteKeyValueWithResponseAsync(settingInternal.getKey(),
- settingInternal.getLabel(), getETag(ifUnchanged, settingInternal), context)
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
+ return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal -> serviceClient
+ .deleteKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(),
+ getETag(ifUnchanged, settingInternal), context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
}
/**
@@ -1001,7 +1001,7 @@ public Mono> setReadOnlyWithResponse(Configuratio
return (isReadOnly
? serviceClient.putLockWithResponseAsync(key, label, null, null, context)
: serviceClient.deleteLockWithResponseAsync(key, label, null, null, context))
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse);
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse);
}));
}
@@ -1036,20 +1036,18 @@ public PagedFlux listConfigurationSettings(SettingSelector
final List matchConditionsList = selector == null ? null : selector.getMatchConditions();
final List tagsFilter = selector == null ? null : selector.getTagsFilter();
AtomicInteger pageETagIndex = new AtomicInteger(0);
- return new PagedFlux<>(() -> withContext(context -> serviceClient.getKeyValuesSinglePageAsync(keyFilter,
- labelFilter, null, acceptDateTime, settingFields, null, null,
+ return new PagedFlux<>(() -> withContext(context -> serviceClient
+ .getKeyValuesSinglePageAsync(keyFilter, labelFilter, null, acceptDateTime, settingFields, null, null,
getPageETag(matchConditionsList, pageETagIndex), tagsFilter, context)
.onErrorResume(HttpResponseException.class,
- (Function>>)
- Utility::handleNotModifiedErrorToValidResponse)
+ (Function>>) Utility::handleNotModifiedErrorToValidResponse)
.map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
- nextLink -> withContext(context -> serviceClient.getKeyValuesNextSinglePageAsync(nextLink,
- acceptDateTime, null, getPageETag(matchConditionsList, pageETagIndex), context)
- .onErrorResume(HttpResponseException.class,
- (Function>>)
- Utility::handleNotModifiedErrorToValidResponse)
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse))
- );
+ nextLink -> withContext(context -> serviceClient
+ .getKeyValuesNextSinglePageAsync(nextLink, acceptDateTime, null,
+ getPageETag(matchConditionsList, pageETagIndex), context)
+ .onErrorResume(HttpResponseException.class,
+ (Function>>) Utility::handleNotModifiedErrorToValidResponse)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)));
}
/**
@@ -1107,12 +1105,13 @@ public PagedFlux listConfigurationSettingsForSnapshot(Stri
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux listConfigurationSettingsForSnapshot(String snapshotName,
List fields) {
- return new PagedFlux<>(() -> withContext(context -> serviceClient.getKeyValuesSinglePageAsync(null, null, null,
- null, fields, snapshotName, null, null, null, context)
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
- nextLink -> withContext(context -> serviceClient.getKeyValuesNextSinglePageAsync(nextLink, null, null, null,
- context)
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)));
+ return new PagedFlux<>(
+ () -> withContext(context -> serviceClient
+ .getKeyValuesSinglePageAsync(null, null, null, null, fields, snapshotName, null, null, null, context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
+ nextLink -> withContext(
+ context -> serviceClient.getKeyValuesNextSinglePageAsync(nextLink, null, null, null, context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)));
}
/**
@@ -1148,12 +1147,13 @@ public PagedFlux listRevisions(SettingSelector selector) {
final String acceptDateTime = selector == null ? null : selector.getAcceptDateTime();
final List settingFields = selector == null ? null : toSettingFieldsList(selector.getFields());
List tags = selector == null ? null : selector.getTagsFilter();
- return new PagedFlux<>(() -> withContext(context -> serviceClient.getRevisionsSinglePageAsync(keyFilter,
- labelFilter, null, acceptDateTime, settingFields, tags, context)
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
- nextLink -> withContext(context -> serviceClient.getRevisionsNextSinglePageAsync(nextLink, acceptDateTime,
- context)
- .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)));
+ return new PagedFlux<>(
+ () -> withContext(context -> serviceClient
+ .getRevisionsSinglePageAsync(keyFilter, labelFilter, null, acceptDateTime, settingFields, tags, context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
+ nextLink -> withContext(
+ context -> serviceClient.getRevisionsNextSinglePageAsync(nextLink, acceptDateTime, context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)));
}
/**
@@ -1186,8 +1186,8 @@ public PagedFlux listRevisions(SettingSelector selector) {
* has failed. The completed operation returns a {@link ConfigurationSnapshot}.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
- public PollerFlux beginCreateSnapshot(
- String snapshotName, ConfigurationSnapshot snapshot) {
+ public PollerFlux beginCreateSnapshot(String snapshotName,
+ ConfigurationSnapshot snapshot) {
return createSnapshotUtilClient.beginCreateSnapshot(snapshotName, snapshot);
}
@@ -1371,8 +1371,8 @@ public Mono recoverSnapshot(String snapshotName) {
* @return A {@link Mono} of {@link ConfigurationSnapshot}.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
- public Mono> recoverSnapshotWithResponse(
- String snapshotName, MatchConditions matchConditions) {
+ public Mono> recoverSnapshotWithResponse(String snapshotName,
+ MatchConditions matchConditions) {
return updateSnapshotAsync(snapshotName, matchConditions, ConfigurationSnapshotStatus.READY, serviceClient);
}
@@ -1398,11 +1398,12 @@ public Mono> recoverSnapshotWithResponse(
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux listSnapshots(SnapshotSelector selector) {
try {
- return new PagedFlux<>(() -> withContext(context -> serviceClient.getSnapshotsSinglePageAsync(
- selector == null ? null : selector.getNameFilter(), null,
- selector == null ? null : selector.getFields(), selector == null ? null : selector.getStatus(),
- context)), nextLink -> withContext(context ->
- serviceClient.getSnapshotsNextSinglePageAsync(nextLink, context)));
+ return new PagedFlux<>(
+ () -> withContext(context -> serviceClient.getSnapshotsSinglePageAsync(
+ selector == null ? null : selector.getNameFilter(), null,
+ selector == null ? null : selector.getFields(), selector == null ? null : selector.getStatus(),
+ context)),
+ nextLink -> withContext(context -> serviceClient.getSnapshotsNextSinglePageAsync(nextLink, context)));
} catch (RuntimeException ex) {
return new PagedFlux<>(() -> monoError(LOGGER, ex));
}
@@ -1456,7 +1457,8 @@ public PagedFlux listLabels() {
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux listLabels(SettingLabelSelector selector) {
final String labelNameFilter = selector == null ? null : selector.getNameFilter();
- final String acceptDatetime = selector == null ? null
+ final String acceptDatetime = selector == null
+ ? null
: selector.getAcceptDateTime() == null ? null : selector.getAcceptDateTime().toString();
final List labelFields = selector == null ? null : selector.getFields();
return serviceClient.getLabelsAsync(labelNameFilter, null, acceptDatetime, labelFields);
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java
index e7e5f47d61a56..d329eea00d41e 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java
@@ -292,7 +292,8 @@
* @see ConfigurationClientBuilder
* @see ConfigurationSetting
*/
-@ServiceClient(builder = ConfigurationClientBuilder.class,
+@ServiceClient(
+ builder = ConfigurationClientBuilder.class,
serviceInterfaces = AzureAppConfigurationImpl.AzureAppConfigurationService.class)
public final class ConfigurationClient {
private static final ClientLogger LOGGER = new ClientLogger(ConfigurationClient.class);
@@ -432,9 +433,8 @@ public Response addConfigurationSettingWithResponse(Config
// This service method call is similar to setConfigurationSetting except we're passing If-Not-Match = "*".
// If the service finds any existing configuration settings, then its e-tag will match and the service will
// return an error.
- final ResponseBase response =
- serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(), null, ETAG_ANY,
- toKeyValue(setting), context);
+ final ResponseBase response = serviceClient.putKeyValueWithResponse(
+ setting.getKey(), setting.getLabel(), null, ETAG_ANY, toKeyValue(setting), context);
return toConfigurationSettingWithResponse(response);
}
@@ -578,9 +578,8 @@ public ConfigurationSetting setConfigurationSetting(ConfigurationSetting setting
public Response setConfigurationSettingWithResponse(ConfigurationSetting setting,
boolean ifUnchanged, Context context) {
validateSetting(setting);
- final ResponseBase response =
- serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting),
- null, toKeyValue(setting), context);
+ final ResponseBase response = serviceClient.putKeyValueWithResponse(
+ setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting), null, toKeyValue(setting), context);
return toConfigurationSettingWithResponse(response);
}
@@ -723,10 +722,9 @@ public Response getConfigurationSettingWithResponse(Config
OffsetDateTime acceptDateTime, boolean ifChanged, Context context) {
validateSetting(setting);
try {
- final ResponseBase response =
- serviceClient.getKeyValueWithResponse(setting.getKey(), setting.getLabel(),
- acceptDateTime == null ? null : acceptDateTime.toString(), null, getETag(ifChanged, setting), null,
- context);
+ final ResponseBase response = serviceClient.getKeyValueWithResponse(
+ setting.getKey(), setting.getLabel(), acceptDateTime == null ? null : acceptDateTime.toString(), null,
+ getETag(ifChanged, setting), null, context);
return toConfigurationSettingWithResponse(response);
} catch (HttpResponseException ex) {
final HttpResponse httpResponse = ex.getResponse();
@@ -762,8 +760,8 @@ public Response getConfigurationSettingWithResponse(Config
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ConfigurationSetting deleteConfigurationSetting(String key, String label) {
- return deleteConfigurationSettingWithResponse(new ConfigurationSetting().setKey(key).setLabel(label),
- false, Context.NONE).getValue();
+ return deleteConfigurationSettingWithResponse(new ConfigurationSetting().setKey(key).setLabel(label), false,
+ Context.NONE).getValue();
}
/**
@@ -850,9 +848,8 @@ public ConfigurationSetting deleteConfigurationSetting(ConfigurationSetting sett
public Response deleteConfigurationSettingWithResponse(ConfigurationSetting setting,
boolean ifUnchanged, Context context) {
validateSetting(setting);
- final ResponseBase response =
- serviceClient.deleteKeyValueWithResponse(setting.getKey(), setting.getLabel(),
- getETag(ifUnchanged, setting), context);
+ final ResponseBase response = serviceClient
+ .deleteKeyValueWithResponse(setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting), context);
return toConfigurationSettingWithResponse(response);
}
@@ -1062,29 +1059,25 @@ public PagedIterable listConfigurationSettings(SettingSele
final List tagsFilter = selector == null ? null : selector.getTagsFilter();
AtomicInteger pageETagIndex = new AtomicInteger(0);
- return new PagedIterable<>(
- () -> {
- PagedResponse pagedResponse;
- try {
- pagedResponse = serviceClient.getKeyValuesSinglePage(keyFilter, labelFilter, null, acceptDateTime,
- settingFields, null, null, getPageETag(matchConditionsList, pageETagIndex),
- tagsFilter, context);
- } catch (HttpResponseException ex) {
- return handleNotModifiedErrorToValidResponse(ex, LOGGER);
- }
- return toConfigurationSettingWithPagedResponse(pagedResponse);
- },
- nextLink -> {
- PagedResponse pagedResponse;
- try {
- pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, acceptDateTime, null,
- getPageETag(matchConditionsList, pageETagIndex), context);
- } catch (HttpResponseException ex) {
- return handleNotModifiedErrorToValidResponse(ex, LOGGER);
- }
- return toConfigurationSettingWithPagedResponse(pagedResponse);
- }
- );
+ return new PagedIterable<>(() -> {
+ PagedResponse pagedResponse;
+ try {
+ pagedResponse = serviceClient.getKeyValuesSinglePage(keyFilter, labelFilter, null, acceptDateTime,
+ settingFields, null, null, getPageETag(matchConditionsList, pageETagIndex), tagsFilter, context);
+ } catch (HttpResponseException ex) {
+ return handleNotModifiedErrorToValidResponse(ex, LOGGER);
+ }
+ return toConfigurationSettingWithPagedResponse(pagedResponse);
+ }, nextLink -> {
+ PagedResponse pagedResponse;
+ try {
+ pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, acceptDateTime, null,
+ getPageETag(matchConditionsList, pageETagIndex), context);
+ } catch (HttpResponseException ex) {
+ return handleNotModifiedErrorToValidResponse(ex, LOGGER);
+ }
+ return toConfigurationSettingWithPagedResponse(pagedResponse);
+ });
}
/**
@@ -1148,8 +1141,8 @@ public PagedIterable listConfigurationSettingsForSnapshot(
fields, snapshotName, null, null, null, context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
}, nextLink -> {
- final PagedResponse pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, null, null,
- null, context);
+ final PagedResponse pagedResponse
+ = serviceClient.getKeyValuesNextSinglePage(nextLink, null, null, null, context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
});
}
@@ -1224,11 +1217,11 @@ public PagedIterable listRevisions(SettingSelector selecto
final PagedResponse pagedResponse = serviceClient.getRevisionsSinglePage(
selector == null ? null : selector.getKeyFilter(), selector == null ? null : selector.getLabelFilter(),
null, acceptDateTime, selector == null ? null : toSettingFieldsList(selector.getFields()),
- selector == null ? null : selector.getTagsFilter(), context);
+ selector == null ? null : selector.getTagsFilter(), context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
}, nextLink -> {
- final PagedResponse pagedResponse = serviceClient.getRevisionsNextSinglePage(nextLink,
- acceptDateTime, context);
+ final PagedResponse pagedResponse
+ = serviceClient.getRevisionsNextSinglePage(nextLink, acceptDateTime, context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
});
}
@@ -1265,8 +1258,8 @@ public PagedIterable listRevisions(SettingSelector selecto
* has failed. The completed operation returns a {@link ConfigurationSnapshot}.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
- public SyncPoller beginCreateSnapshot(
- String snapshotName, ConfigurationSnapshot snapshot, Context context) {
+ public SyncPoller beginCreateSnapshot(String snapshotName,
+ ConfigurationSnapshot snapshot, Context context) {
return createSnapshotUtilClient.beginCreateSnapshot(snapshotName, snapshot, context);
}
@@ -1324,9 +1317,9 @@ public ConfigurationSnapshot getSnapshot(String snapshotName) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response getSnapshotWithResponse(String snapshotName, List fields,
- Context context) {
- final ResponseBase response =
- serviceClient.getSnapshotWithResponse(snapshotName, null, null, fields, context);
+ Context context) {
+ final ResponseBase response
+ = serviceClient.getSnapshotWithResponse(snapshotName, null, null, fields, context);
return new SimpleResponse<>(response, response.getValue());
}
@@ -1349,8 +1342,8 @@ public Response getSnapshotWithResponse(String snapshotNa
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ConfigurationSnapshot archiveSnapshot(String snapshotName) {
- return updateSnapshotSync(snapshotName, null, ConfigurationSnapshotStatus.ARCHIVED, serviceClient,
- Context.NONE).getValue();
+ return updateSnapshotSync(snapshotName, null, ConfigurationSnapshotStatus.ARCHIVED, serviceClient, Context.NONE)
+ .getValue();
}
/**
@@ -1408,8 +1401,8 @@ public Response archiveSnapshotWithResponse(String snapsh
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public ConfigurationSnapshot recoverSnapshot(String snapshotName) {
- return updateSnapshotSync(snapshotName, null, ConfigurationSnapshotStatus.READY, serviceClient,
- Context.NONE).getValue();
+ return updateSnapshotSync(snapshotName, null, ConfigurationSnapshotStatus.READY, serviceClient, Context.NONE)
+ .getValue();
}
/**
@@ -1496,9 +1489,10 @@ public PagedIterable listSnapshots(SnapshotSelector selec
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listSnapshots(SnapshotSelector selector, Context context) {
- return new PagedIterable<>(() -> serviceClient.getSnapshotsSinglePage(
- selector == null ? null : selector.getNameFilter(), null, selector == null ? null : selector.getFields(),
- selector == null ? null : selector.getStatus(), context),
+ return new PagedIterable<>(
+ () -> serviceClient.getSnapshotsSinglePage(selector == null ? null : selector.getNameFilter(), null,
+ selector == null ? null : selector.getFields(), selector == null ? null : selector.getStatus(),
+ context),
nextLink -> serviceClient.getSnapshotsNextSinglePage(nextLink, context));
}
@@ -1580,7 +1574,8 @@ public PagedIterable listLabels(SettingLabelSelector selector) {
public PagedIterable listLabels(SettingLabelSelector selector, Context context) {
final String labelNameFilter = selector == null ? null : selector.getNameFilter();
final String acceptDatetime = selector == null
- ? null : selector.getAcceptDateTime() == null ? null : selector.getAcceptDateTime().toString();
+ ? null
+ : selector.getAcceptDateTime() == null ? null : selector.getAcceptDateTime().toString();
final List labelFields = selector == null ? null : selector.getFields();
return serviceClient.getLabels(labelNameFilter, null, acceptDatetime, labelFields, context);
}
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java
index 700a764f4accf..864f7402064dd 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java
@@ -108,13 +108,10 @@
* @see ConfigurationAsyncClient
* @see ConfigurationClient
*/
-@ServiceClientBuilder(serviceClients = {ConfigurationAsyncClient.class, ConfigurationClient.class})
-public final class ConfigurationClientBuilder implements
- TokenCredentialTrait,
- ConnectionStringTrait,
- HttpTrait,
- ConfigurationTrait,
- EndpointTrait {
+@ServiceClientBuilder(serviceClients = { ConfigurationAsyncClient.class, ConfigurationClient.class })
+public final class ConfigurationClientBuilder implements TokenCredentialTrait,
+ ConnectionStringTrait, HttpTrait,
+ ConfigurationTrait, EndpointTrait {
private static final String CLIENT_NAME;
private static final String CLIENT_VERSION;
@@ -125,8 +122,7 @@ public final class ConfigurationClientBuilder implements
Map properties = CoreUtils.getProperties("azure-data-appconfiguration.properties");
CLIENT_NAME = properties.getOrDefault("name", "UnknownName");
CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion");
- ADD_HEADERS_POLICY = new AddHeadersPolicy(new HttpHeaders()
- .set("x-ms-return-client-request-id", "true")
+ ADD_HEADERS_POLICY = new AddHeadersPolicy(new HttpHeaders().set("x-ms-return-client-request-id", "true")
.set(HttpHeaderName.CONTENT_TYPE, "application/json")
.set(HttpHeaderName.ACCEPT, "application/vnd.microsoft.azconfig.kv+json"));
}
@@ -221,8 +217,8 @@ private AzureAppConfigurationImpl buildInnerClient(SyncTokenPolicy syncTokenPoli
+ "TokenCredential should be null if using connection string, vice versa."));
} else if (tokenCredential == null) {
if (connectionString.isEmpty()) {
- throw LOGGER.logExceptionAsError(
- new IllegalArgumentException("'connectionString' cannot be an empty string."));
+ throw LOGGER
+ .logExceptionAsError(new IllegalArgumentException("'connectionString' cannot be an empty string."));
}
credentialsLocal = new ConfigurationClientCredentials(connectionString);
endpointLocal = credentialsLocal.getBaseUri();
@@ -231,9 +227,8 @@ private AzureAppConfigurationImpl buildInnerClient(SyncTokenPolicy syncTokenPoli
}
// Service version
- ConfigurationServiceVersion serviceVersion = (version != null)
- ? version
- : ConfigurationServiceVersion.getLatest();
+ ConfigurationServiceVersion serviceVersion
+ = (version != null) ? version : ConfigurationServiceVersion.getLatest();
// Don't share the default auto-created pipeline between App Configuration client instances.
HttpPipeline buildPipeline = (pipeline == null)
? createDefaultHttpPipeline(syncTokenPolicy, credentialsLocal, tokenCredentialLocal)
@@ -245,9 +240,8 @@ private AzureAppConfigurationImpl buildInnerClient(SyncTokenPolicy syncTokenPoli
private HttpPipeline createDefaultHttpPipeline(SyncTokenPolicy syncTokenPolicy,
ConfigurationClientCredentials credentials, TokenCredential tokenCredential) {
// Global Env configuration store
- Configuration buildConfiguration = (configuration == null)
- ? Configuration.getGlobalConfiguration()
- : configuration;
+ Configuration buildConfiguration
+ = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
// Endpoint
String buildEndpoint = endpoint;
@@ -260,8 +254,8 @@ private HttpPipeline createDefaultHttpPipeline(SyncTokenPolicy syncTokenPolicy,
ClientOptions localClientOptions = clientOptions != null ? clientOptions : DEFAULT_CLIENT_OPTIONS;
// Closest to API goes first, closest to wire goes last.
final List policies = new ArrayList<>();
- policies.add(new UserAgentPolicy(
- getApplicationId(localClientOptions, httpLogOptions), CLIENT_NAME, CLIENT_VERSION, buildConfiguration));
+ policies.add(new UserAgentPolicy(getApplicationId(localClientOptions, httpLogOptions), CLIENT_NAME,
+ CLIENT_VERSION, buildConfiguration));
policies.add(new RequestIdPolicy());
policies.add(new AddHeadersFromContextPolicy());
policies.add(ADD_HEADERS_POLICY);
@@ -276,8 +270,7 @@ private HttpPipeline createDefaultHttpPipeline(SyncTokenPolicy syncTokenPolicy,
if (tokenCredential != null) {
// User token based policy
- policies.add(
- new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s/.default", endpoint)));
+ policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s/.default", endpoint)));
} else if (credentials != null) {
// Use credentialS based policy
policies.add(new ConfigurationCredentialsPolicy(credentials));
@@ -290,17 +283,15 @@ private HttpPipeline createDefaultHttpPipeline(SyncTokenPolicy syncTokenPolicy,
policies.addAll(perRetryPolicies);
List httpHeaderList = new ArrayList<>();
- localClientOptions.getHeaders().forEach(
- header -> httpHeaderList.add(new HttpHeader(header.getName(), header.getValue())));
+ localClientOptions.getHeaders()
+ .forEach(header -> httpHeaderList.add(new HttpHeader(header.getName(), header.getValue())));
policies.add(new AddHeadersPolicy(new HttpHeaders(httpHeaderList)));
-
HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(httpLogOptions));
// customized pipeline
- return new HttpPipelineBuilder()
- .policies(policies.toArray(new HttpPipelinePolicy[0]))
+ return new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient)
.tracer(createTracer(clientOptions))
.clientOptions(localClientOptions)
@@ -547,4 +538,3 @@ public ConfigurationClientBuilder serviceVersion(ConfigurationServiceVersion ver
return this;
}
}
-
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationClientCredentials.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationClientCredentials.java
index bf89f3e7eb86f..5378093574c76 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationClientCredentials.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationClientCredentials.java
@@ -61,7 +61,6 @@ public String getBaseUri() {
return this.credentials.baseUri().toString();
}
-
/**
* Sets the {@code Authorization} header on the request.
*
@@ -96,17 +95,16 @@ void setAuthorizationHeaders(HttpRequest httpRequest) {
String signed = url.getHost() + ";" + date + ";" + contentHash;
- headers.set(HttpHeaderName.HOST, url.getHost())
- .set(X_MS_CONTENT_SHA256, contentHash);
+ headers.set(HttpHeaderName.HOST, url.getHost()).set(X_MS_CONTENT_SHA256, contentHash);
// String-To-Sign=HTTP_METHOD + '\n' + path_and_query + '\n' + signed_headers_values
// Signed headers: "host;x-ms-date;x-ms-content-sha256"
// The line separator has to be \n. Using %n with String.format will result in a 401 from the service.
- String stringToSign = httpRequest.getHttpMethod().toString().toUpperCase(Locale.US)
- + "\n" + pathAndQuery + "\n" + signed;
+ String stringToSign
+ = httpRequest.getHttpMethod().toString().toUpperCase(Locale.US) + "\n" + pathAndQuery + "\n" + signed;
- String signature = Base64.getEncoder()
- .encodeToString(sha256HMAC.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)));
+ String signature
+ = Base64.getEncoder().encodeToString(sha256HMAC.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)));
headers.set(HttpHeaderName.AUTHORIZATION, "HMAC-SHA256 Credential=" + credentials.id()
+ "&SignedHeaders=Host;Date;x-ms-content-sha256&Signature=" + signature);
} catch (GeneralSecurityException e) {
@@ -170,8 +168,10 @@ byte[] secret() {
this.id = id;
this.secret = secret;
- if (this.baseUri == null || CoreUtils.isNullOrEmpty(this.id)
- || this.secret == null || this.secret.length == 0) {
+ if (this.baseUri == null
+ || CoreUtils.isNullOrEmpty(this.id)
+ || this.secret == null
+ || this.secret.length == 0) {
throw new IllegalArgumentException("Could not parse 'connectionString'."
+ " Expected format: 'endpoint={endpoint};id={id};secret={secret}'. Actual:" + connectionString);
}
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialsPolicy.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialsPolicy.java
index 7e0323605a94a..cdc1910f6f756 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialsPolicy.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialsPolicy.java
@@ -69,4 +69,3 @@ public HttpResponse processSync(HttpPipelineCallContext context, HttpPipelineNex
return next.processSync();
}
}
-
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializationHelper.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializationHelper.java
index 18a7406ae89b2..a64ca2f7542c0 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializationHelper.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializationHelper.java
@@ -39,14 +39,14 @@ public final class ConfigurationSettingDeserializationHelper {
private static final ClientLogger LOGGER = new ClientLogger(Utility.class);
static final String FEATURE_FLAG_CONTENT_TYPE = "application/vnd.microsoft.appconfig.ff+json;charset=utf-8";
- static final String SECRET_REFERENCE_CONTENT_TYPE =
- "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8";
+ static final String SECRET_REFERENCE_CONTENT_TYPE
+ = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8";
/*
* Utility method for translating KeyValue to ConfigurationSetting with PagedResponse.
*/
- public static PagedResponseBase