Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAD sample and README revised, and correct indentation #7074

Merged
merged 6 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions sdk/appconfiguration/azure-data-appconfiguration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ The client performs the interactions with the App Configuration service, getting

An application that needs to retrieve startup configurations is better suited using the synchronous client, for example setting up a SQL connection.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L64-L75 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L64-L76 -->
```Java
ConfigurationClient configurationClient = new ConfigurationClientBuilder()
.connectionString(connectionString)
Expand All @@ -223,14 +223,15 @@ String url = configurationClient.getConfigurationSetting(urlKey, urlLabel).getVa
Connection conn;
try {
conn = DriverManager.getConnection(url);
conn.close();
mssfang marked this conversation as resolved.
Show resolved Hide resolved
} catch (SQLException ex) {
System.out.printf("Failed to get connection using url %s", url);
}
```

An application that has a large set of configurations that it needs to periodically update is be better suited using the asynchronous client, for example all settings with a specific label are periodically updated.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L79-L84 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L80-L85 -->
```Java
ConfigurationAsyncClient configurationClient = new ConfigurationClientBuilder()
.connectionString(connectionString)
Expand Down Expand Up @@ -261,7 +262,7 @@ Create a configuration setting to be stored in the configuration store. There ar

- `addConfigurationSetting` creates a setting only if the setting does not already exist in the store.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L88-L88 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L89-L89 -->
```Java
ConfigurationSetting setting = configurationClient.addConfigurationSetting("new_key", "new_label", "new_value");
```
Expand All @@ -270,7 +271,7 @@ Or

- `setConfigurationSetting` creates a setting if it doesn't exist or overrides an existing setting.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L92-L92 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L93-L93 -->
```Java
ConfigurationSetting setting = configurationClient.setConfigurationSetting("some_key", "some_label", "some_value");
```
Expand All @@ -279,7 +280,7 @@ ConfigurationSetting setting = configurationClient.setConfigurationSetting("some

Retrieve a previously stored configuration setting by calling `getConfigurationSetting`.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L96-L97 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L97-L98 -->
```Java
ConfigurationSetting setting = configurationClient.setConfigurationSetting("some_key", "some_label", "some_value");
ConfigurationSetting retrievedSetting = configurationClient.getConfigurationSetting("some_key", "some_label");
Expand All @@ -290,7 +291,7 @@ When `ifChanged` is true, the configuration setting is only retrieved if it is d
This is determined by comparing the ETag of the `setting` to the one in the service to see if they are the same or not.
If the ETags are not the same, it means the configuration setting is different, and its value is retrieved.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L101-L102 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L102-L103 -->
```Java
ConfigurationSetting setting = configurationClient.setConfigurationSetting("some_key", "some_label", "some_value");
Response<ConfigurationSetting> settingResponse = configurationClient.getConfigurationSettingWithResponse(setting, null, true, Context.NONE);
Expand All @@ -300,7 +301,7 @@ Response<ConfigurationSetting> settingResponse = configurationClient.getConfigur

Update an existing configuration setting by calling `setConfigurationSetting`.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L106-L107 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L107-L108 -->
```Java
ConfigurationSetting setting = configurationClient.setConfigurationSetting("some_key", "some_label", "some_value");
ConfigurationSetting updatedSetting = configurationClient.setConfigurationSetting("some_key", "some_label", "new_value");
Expand All @@ -311,7 +312,7 @@ true. When `ifUnchanged` is true, the configuration setting is only updated if i
This is determined by comparing the ETag of the `setting` to the one in the service to see if they are the same or not.
If the ETag are the same, it means the configuration setting is same, and its value is updated.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L111-L112 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L112-L113 -->
```Java
ConfigurationSetting setting = configurationClient.setConfigurationSetting("some_key", "some_label", "some_value");
Response<ConfigurationSetting> settingResponse = configurationClient.setConfigurationSettingWithResponse(setting, true, Context.NONE);
Expand All @@ -321,7 +322,7 @@ Response<ConfigurationSetting> settingResponse = configurationClient.setConfigur

Delete an existing configuration setting by calling `deleteConfigurationSetting`.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L116-L117 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L117-L118 -->
```Java
ConfigurationSetting setting = configurationClient.setConfigurationSetting("some_key", "some_label", "some_value");
ConfigurationSetting deletedSetting = configurationClient.deleteConfigurationSetting("some_key", "some_label");
Expand All @@ -331,7 +332,7 @@ to true. When `ifUnchanged` parameter to true. When `ifUnchanged` is true, the c
it is same as the given `setting`. This is determined by comparing the ETag of the `setting` to the one in the service
to see if they are the same or not. If the ETag are same, it means the configuration setting is same, and its value is deleted.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L121-L122 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L122-L123 -->
```Java
ConfigurationSetting setting = configurationClient.setConfigurationSetting("some_key", "some_label", "some_value");
Response<ConfigurationSetting> settingResponse = configurationClient.deleteConfigurationSettingWithResponse(setting, true, Context.NONE);
Expand All @@ -342,7 +343,7 @@ Response<ConfigurationSetting> settingResponse = configurationClient.deleteConfi
List multiple configuration settings by calling `listConfigurationSettings`.
Pass a null `SettingSelector` into the method if you want to fetch all the configuration settings and their fields.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L126-L131 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L127-L132 -->
```Java
String key = "some_key";
String key2 = "new_key";
Expand All @@ -356,7 +357,7 @@ PagedIterable<ConfigurationSetting> settings = configurationClient.listConfigura

List all revisions of a configuration setting by calling `listRevisions`.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L135-L139 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L136-L140 -->
```Java
String key = "revisionKey";
configurationClient.setConfigurationSetting(key, "some_label", "some_value");
Expand All @@ -369,7 +370,7 @@ PagedIterable<ConfigurationSetting> settings = configurationClient.listRevisions

Set a configuration setting to read-only status.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L143-L144 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L144-L145 -->
```Java
configurationClient.setConfigurationSetting("some_key", "some_label", "some_value");
ConfigurationSetting setting = configurationClient.setReadOnly("some_key", "some_label", true);
Expand All @@ -378,7 +379,7 @@ ConfigurationSetting setting = configurationClient.setReadOnly("some_key", "some

Clear read-only from a configuration setting.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L148-L148 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L149-L149 -->
```Java
ConfigurationSetting setting = configurationClient.setReadOnly("some_key", "some_label", false);
```
Expand All @@ -391,7 +392,7 @@ When you interact with App Configuration using this Java client library, errors

App Configuration provides a way to define customized headers through `Context` object in the public API.

<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L152-L161 -->
<!-- embedme ./src/samples/java/com/azure/data/appconfiguration/ReadmeSamples.java#L153-L162 -->
```java
// Add your headers
HttpHeaders headers = new HttpHeaders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public void sqlExample() {
Connection conn;
try {
conn = DriverManager.getConnection(url);
conn.close();
} catch (SQLException ex) {
System.out.printf("Failed to get connection using url %s", url);
}
Expand Down