Skip to content

Commit

Permalink
[AppConfig] Merged feature branch to main repo (#41250)
Browse files Browse the repository at this point in the history
  • Loading branch information
mssfang authored Jul 31, 2024
1 parent 9286b6a commit eed41c1
Show file tree
Hide file tree
Showing 80 changed files with 4,006 additions and 3,708 deletions.
17 changes: 17 additions & 0 deletions sdk/appconfiguration/azure-data-appconfiguration/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Release History

## 1.7.0-beta.1 (Unreleased)

### Features Added

- Added a new service API support: `2023-11-01`.
- Added a new method `listLabels` to support listing labels capabilities.
- Added new class `SettingLabel` and `SettingLabelSelector`, and a new enum `SettingLabelFields`.
- Added a new property `tagsFilter` to `SettingSelector` to support filtering settings or revisions with tags filter.
- Added a new property `tags` to `ConfigurationSettingsFilter` to support filtering settings with tags filter for snapshot.

### Breaking Changes

### Bugs Fixed

### Other Changes


## 1.6.3 (2024-07-26)

### Bugs Fixed
Expand Down
14 changes: 14 additions & 0 deletions sdk/appconfiguration/azure-data-appconfiguration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ For "Feature Flag" and "Secret Reference" configuration settings, see [samples][
* [Recover a snapshot](#recover-a-snapshot)
* [Retrieve all Snapshots](#retrieve-all-snapshots)
* [Retrieve Configuration Settings in a Snapshot](#retrieve-configuration-settings-in-a-snapshot)
* [Retrieve Labels](#retrieve-labels)

### Create a Configuration Client

Expand Down Expand Up @@ -400,6 +401,7 @@ configurationClient.setConfigurationSetting(key2, "new_label", "new_value");
SettingSelector selector = new SettingSelector().setKeyFilter(key + "," + key2);
PagedIterable<ConfigurationSetting> settings = configurationClient.listConfigurationSettings(selector);
```
For more filters see class `SettingSelector`, such as `tagsFilter` see [samples][samples].

### List revisions of multiple Configuration Settings

Expand Down Expand Up @@ -535,6 +537,18 @@ for (ConfigurationSetting setting : configurationSettings) {
}
```

### Retrieve Labels
List multiple labels in the App Configuration store by calling `listLabels`.

```java readme-sample-listLabels
String labelNameFilter = "{labelNamePrefix}*";
configurationClient.listLabels(new SettingLabelSelector().setNameFilter(labelNameFilter))
.forEach(label -> {
System.out.println("label name = " + label.getName());
});
```


## Troubleshooting

### General
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/appconfiguration/azure-data-appconfiguration",
"Tag": "java/appconfiguration/azure-data-appconfiguration_1d33b52d2b"
"Tag": "java/appconfiguration/azure-data-appconfiguration_5e00bac278"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
import com.azure.data.appconfiguration.models.ConfigurationSnapshot;
import com.azure.data.appconfiguration.models.ConfigurationSnapshotStatus;
import com.azure.data.appconfiguration.models.FeatureFlagConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingLabelSelector;
import com.azure.data.appconfiguration.models.SecretReferenceConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingFields;
import com.azure.data.appconfiguration.models.SettingLabel;
import com.azure.data.appconfiguration.models.SettingLabelFields;
import com.azure.data.appconfiguration.models.SettingSelector;
import com.azure.data.appconfiguration.models.SnapshotFields;
import com.azure.data.appconfiguration.models.SnapshotSelector;
Expand Down Expand Up @@ -1031,10 +1034,11 @@ public PagedFlux<ConfigurationSetting> listConfigurationSettings(SettingSelector
final String acceptDateTime = selector == null ? null : selector.getAcceptDateTime();
final List<SettingFields> settingFields = selector == null ? null : toSettingFieldsList(selector.getFields());
final List<MatchConditions> matchConditionsList = selector == null ? null : selector.getMatchConditions();
final List<String> 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,
getPageETag(matchConditionsList, pageETagIndex), context)
getPageETag(matchConditionsList, pageETagIndex), tagsFilter, context)
.onErrorResume(HttpResponseException.class,
(Function<HttpResponseException, Mono<PagedResponse<KeyValue>>>)
Utility::handleNotModifiedErrorToValidResponse)
Expand Down Expand Up @@ -1104,7 +1108,7 @@ public PagedFlux<ConfigurationSetting> listConfigurationSettingsForSnapshot(Stri
public PagedFlux<ConfigurationSetting> listConfigurationSettingsForSnapshot(String snapshotName,
List<SettingFields> fields) {
return new PagedFlux<>(() -> withContext(context -> serviceClient.getKeyValuesSinglePageAsync(null, null, null,
null, fields, snapshotName, null, null, context)
null, fields, snapshotName, null, null, null, context)
.map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
nextLink -> withContext(context -> serviceClient.getKeyValuesNextSinglePageAsync(nextLink, null, null, null,
context)
Expand Down Expand Up @@ -1143,8 +1147,9 @@ public PagedFlux<ConfigurationSetting> listRevisions(SettingSelector selector) {
final String labelFilter = selector == null ? null : selector.getLabelFilter();
final String acceptDateTime = selector == null ? null : selector.getAcceptDateTime();
final List<SettingFields> settingFields = selector == null ? null : toSettingFieldsList(selector.getFields());
List<String> tags = selector == null ? null : selector.getTagsFilter();
return new PagedFlux<>(() -> withContext(context -> serviceClient.getRevisionsSinglePageAsync(keyFilter,
labelFilter, null, acceptDateTime, settingFields, context)
labelFilter, null, acceptDateTime, settingFields, tags, context)
.map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
nextLink -> withContext(context -> serviceClient.getRevisionsNextSinglePageAsync(nextLink, acceptDateTime,
context)
Expand Down Expand Up @@ -1403,6 +1408,60 @@ public PagedFlux<ConfigurationSnapshot> listSnapshots(SnapshotSelector selector)
}
}

/**
* Gets all labels.
*
* <p><strong>Code Samples</strong></p>
*
* <!-- src_embed com.azure.data.appconfiguration.configurationasyncclient.listAllLabels -->
* <pre>
* client.listLabels&#40;&#41;
* .subscribe&#40;label -&gt; &#123;
* System.out.println&#40;&quot;label name = &quot; + label&#41;;
* &#125;&#41;;
* </pre>
* <!-- end com.azure.data.appconfiguration.configurationasyncclient.listAllLabels -->
*
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a list of labels as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<SettingLabel> listLabels() {
return listLabels(null);
}

/**
* Gets a list of labels by given {@link SettingLabelSelector}
*
* <p><strong>Code Samples</strong></p>
*
* <!-- src_embed com.azure.data.appconfiguration.configurationasyncclient.listLabels -->
* <pre>
* String labelNameFilter = &quot;&#123;labelNamePrefix&#125;*&quot;;
* client.listLabels&#40;new SettingLabelSelector&#40;&#41;.setNameFilter&#40;labelNameFilter&#41;&#41;
* .subscribe&#40;label -&gt; &#123;
* System.out.println&#40;&quot;label name = &quot; + label&#41;;
* &#125;&#41;;
* </pre>
* <!-- end com.azure.data.appconfiguration.configurationasyncclient.listLabels -->
*
* @param selector Optional. Selector to filter labels from the service.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a list of labels as paginated response with {@link PagedFlux}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<SettingLabel> listLabels(SettingLabelSelector selector) {
final String labelNameFilter = selector == null ? null : selector.getNameFilter();
final String acceptDatetime = selector == null ? null
: selector.getAcceptDateTime() == null ? null : selector.getAcceptDateTime().toString();
final List<SettingLabelFields> labelFields = selector == null ? null : selector.getFields();
return serviceClient.getLabelsAsync(labelNameFilter, null, acceptDatetime, labelFields);
}

/**
* Adds an external synchronization token to ensure service requests receive up-to-date values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
import com.azure.data.appconfiguration.models.ConfigurationSnapshot;
import com.azure.data.appconfiguration.models.ConfigurationSnapshotStatus;
import com.azure.data.appconfiguration.models.FeatureFlagConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingLabelSelector;
import com.azure.data.appconfiguration.models.SecretReferenceConfigurationSetting;
import com.azure.data.appconfiguration.models.SettingFields;
import com.azure.data.appconfiguration.models.SettingLabel;
import com.azure.data.appconfiguration.models.SettingLabelFields;
import com.azure.data.appconfiguration.models.SettingSelector;
import com.azure.data.appconfiguration.models.SnapshotFields;
import com.azure.data.appconfiguration.models.SnapshotSelector;
Expand Down Expand Up @@ -1056,27 +1059,31 @@ public PagedIterable<ConfigurationSetting> listConfigurationSettings(SettingSele
final String acceptDateTime = selector == null ? null : selector.getAcceptDateTime();
final List<SettingFields> settingFields = selector == null ? null : toSettingFieldsList(selector.getFields());
final List<MatchConditions> matchConditionsList = selector == null ? null : selector.getMatchConditions();
final List<String> tagsFilter = selector == null ? null : selector.getTagsFilter();

AtomicInteger pageETagIndex = new AtomicInteger(0);
return new PagedIterable<>(() -> {
PagedResponse<KeyValue> pagedResponse;
try {
pagedResponse = serviceClient.getKeyValuesSinglePage(keyFilter, labelFilter, null, acceptDateTime,
settingFields, null, null, getPageETag(matchConditionsList, pageETagIndex), context);
} catch (HttpResponseException ex) {
return handleNotModifiedErrorToValidResponse(ex, LOGGER);
}
return toConfigurationSettingWithPagedResponse(pagedResponse);
},
nextLink -> {
PagedResponse<KeyValue> pagedResponse;
try {
pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, acceptDateTime, null,
getPageETag(matchConditionsList, pageETagIndex), context);
} catch (HttpResponseException ex) {
return handleNotModifiedErrorToValidResponse(ex, LOGGER);
return new PagedIterable<>(
() -> {
PagedResponse<KeyValue> 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<KeyValue> pagedResponse;
try {
pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, acceptDateTime, null,
getPageETag(matchConditionsList, pageETagIndex), context);
} catch (HttpResponseException ex) {
return handleNotModifiedErrorToValidResponse(ex, LOGGER);
}
return toConfigurationSettingWithPagedResponse(pagedResponse);
}
return toConfigurationSettingWithPagedResponse(pagedResponse);
}
);
}

Expand Down Expand Up @@ -1138,7 +1145,7 @@ public PagedIterable<ConfigurationSetting> listConfigurationSettingsForSnapshot(
List<SettingFields> fields, Context context) {
return new PagedIterable<>(() -> {
final PagedResponse<KeyValue> pagedResponse = serviceClient.getKeyValuesSinglePage(null, null, null, null,
fields, snapshotName, null, null, context);
fields, snapshotName, null, null, null, context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
}, nextLink -> {
final PagedResponse<KeyValue> pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, null, null,
Expand Down Expand Up @@ -1216,7 +1223,8 @@ public PagedIterable<ConfigurationSetting> listRevisions(SettingSelector selecto
return new PagedIterable<>(() -> {
final PagedResponse<KeyValue> pagedResponse = serviceClient.getRevisionsSinglePage(
selector == null ? null : selector.getKeyFilter(), selector == null ? null : selector.getLabelFilter(),
null, acceptDateTime, selector == null ? null : toSettingFieldsList(selector.getFields()), context);
null, acceptDateTime, selector == null ? null : toSettingFieldsList(selector.getFields()),
selector == null ? null : selector.getTagsFilter(), context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
}, nextLink -> {
final PagedResponse<KeyValue> pagedResponse = serviceClient.getRevisionsNextSinglePage(nextLink,
Expand Down Expand Up @@ -1494,6 +1502,89 @@ public PagedIterable<ConfigurationSnapshot> listSnapshots(SnapshotSelector selec
nextLink -> serviceClient.getSnapshotsNextSinglePage(nextLink, context));
}

/**
* Gets all labels
*
* <p><strong>Code Samples</strong></p>
*
* <!-- src_embed com.azure.data.appconfiguration.configurationclient.listAllLabels -->
* <pre>
* client.listLabels&#40;&#41;
* .forEach&#40;label -&gt; &#123;
* System.out.println&#40;&quot;label name = &quot; + label.getName&#40;&#41;&#41;;
* &#125;&#41;;
* </pre>
* <!-- end com.azure.data.appconfiguration.configurationclient.listAllLabels -->
*
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a list of labels as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<SettingLabel> listLabels() {
return listLabels(null);
}

/**
* Gets a list of labels by given {@link SettingLabelSelector}.
*
* <p><strong>Code Samples</strong></p>
*
* <!-- src_embed com.azure.data.appconfiguration.configurationclient.listLabels -->
* <pre>
* String labelNameFilter = &quot;&#123;labelNamePrefix&#125;*&quot;;
* client.listLabels&#40;new SettingLabelSelector&#40;&#41;.setNameFilter&#40;labelNameFilter&#41;&#41;
* .forEach&#40;label -&gt; &#123;
* System.out.println&#40;&quot;label name = &quot; + label.getName&#40;&#41;&#41;;
* &#125;&#41;;
* </pre>
* <!-- end com.azure.data.appconfiguration.configurationclient.listLabels -->
*
* @param selector Optional. Selector to filter labels from the service.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a list of labels as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<SettingLabel> listLabels(SettingLabelSelector selector) {
return listLabels(selector, Context.NONE);
}

/**
* Gets a list of labels by given {@link SettingLabelSelector}.
*
* <p><strong>Code Samples</strong></p>
*
* <!-- src_embed com.azure.data.appconfiguration.configurationclient.listLabelsMaxOverload -->
* <pre>
* String labelNameFilter = &quot;&#123;labelNamePrefix&#125;*&quot;;
* Context ctx = new Context&#40;key2, value2&#41;;
*
* client.listLabels&#40;new SettingLabelSelector&#40;&#41;.setNameFilter&#40;labelNameFilter&#41;, ctx&#41;
* .forEach&#40;label -&gt; &#123;
* System.out.println&#40;&quot;label name = &quot; + label.getName&#40;&#41;&#41;;
* &#125;&#41;;
* </pre>
* <!-- end com.azure.data.appconfiguration.configurationclient.listLabelsMaxOverload -->
*
* @param selector Optional. Selector to filter labels from the service.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a list of labels as paginated response with {@link PagedIterable}.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<SettingLabel> 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();
final List<SettingLabelFields> labelFields = selector == null ? null : selector.getFields();
return serviceClient.getLabels(labelNameFilter, null, acceptDatetime, labelFields, context);
}

/**
* Adds an external synchronization token to ensure service requests receive up-to-date values.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ public enum ConfigurationServiceVersion implements ServiceVersion {
/**
* Service version {@code 2023-10-01}.
*/
V2023_10_01("2023-10-01");
V2023_10_01("2023-10-01"),

/**
* Service version {@code 2023-11-01}.
*/
V2023_11_01("2023-11-01");

private final String version;

Expand All @@ -39,6 +44,6 @@ public String getVersion() {
* @return the latest {@link ConfigurationServiceVersion}
*/
public static ConfigurationServiceVersion getLatest() {
return V2023_10_01;
return V2023_11_01;
}
}
Loading

0 comments on commit eed41c1

Please sign in to comment.